How do I make the image map link to be a parameter coming from the database?

0

I would like in the image tag area of the map in the href attribute instead of putting the page link I want it to receive a parameter that is sent to a C # method.

HTML code

    <img src="../css/image/cores.png"   alt="Escolha a cor que deseja" usemap="#Cores" onclick="ImageMap_Click"/>
    <map name="Cores">
        <area  shape="rect" alt="Rosa" coords="8,8,96,116" href="<%#Eval("")%>">
         <area  shape="rect" alt="Rosas" coords="111,12,201,105" href="#"/>
        <area  shape="rect" alt="Rosa" coords="208,8,307,109" href="#"/>
        <area  shape="rect" alt="Rosa" coords="312,11,406,111" href="#"/>
        <area  shape="rect" alt="Rosa" coords="415,10,509,109" href="#"/>
        <area  shape="rect" alt="Rosa" coords="515,12,606,107" href="#"/>
        <area  shape="rect" alt="Rosa" coords="9,115,102,213" href="#"/>
        <area  shape="rect" alt="Rosa" coords="108,116,197,209" href="#"/>
        <area  shape="rect" alt="Rosa" coords="210,114,298,208" href="#"/>
        <area  shape="rect" alt="Rosa" coords="311,114,402,210" href="#"/>
        <area  shape="rect" alt="Rosa" coords="416,115,508,213" href="#"/>
        <area  shape="rect" alt="Rosa" coords="514,115,602,213" href="#"/>
        <area  shape="rect" alt="Rosa" coords="110,222,204,319" href="#"/>
        <area  shape="rect" alt="Rosa" coords="313,115,403,207" href="#"/>


         <area  shape="rect" alt="Rosa" coords="6,220,100,317" href="#"/>
        <area  shape="rect" alt="Rosa" coords="210,221,298,314" href="#"/>
        <area  shape="rect" alt="Rosa" coords="313,222,401,316" href="#"/>
        <area  shape="rect" alt="Rosa" coords="412,220,505,319" href="#"/>
        <area  shape="rect" alt="Rosa" coords="515,219,602,316" href="#"/>
        <area  shape="rect" alt="Rosa" coords="7,327,92,419" href="#"/>
        <area  shape="rect" alt="Rosa" coords="109,329,198,422" href="#"/>
        <area  shape="rect" alt="Rosa" coords="514,223,603,421" href="#"/>


        <area  shape="rect" alt="Rosa" coords="209,329,295,420" href="#"/>
        <area  shape="rect" alt="Rosa" coords="313,327,402,417" href="#"/>

        <area  shape="rect" alt="Rosa" coords="414,330,504,421" href="#"/>

        <area  shape="rect" alt="Rosa" coords="512,329,600,220" href="#"/>
    </map>

C #

public static DataTable GetProductsInAtributes (string CategoryID, string pageNumber, out int howManyPages)        {

      *DbCommand comm = GenericDataAcess.CreateCommand();
       comm.CommandText = "GetProdutoinAtributos";
       //cria um novo parametro
       DbParameter param = comm.CreateParameter();
       param.ParameterName = "@atributoValueID";
       param.Value = categoriaID;
       param.DbType = DbType.Int32;
       comm.Parameters.Add(param);* 

// THIS IS HERE I HAVE THE PARAMETER @atributoValueID

       //cria um novo parametro
       param = comm.CreateParameter();
       param.ParameterName = "@DescricaoTamnaho";
       param.Value = TendenciasConfigurations.ProdDescricaoTamnaho;
       param.DbType = DbType.Int32;
       comm.Parameters.Add(param);

       //cria um novo parametro
       param = comm.CreateParameter();
       param.ParameterName = "@Numpagina";
       param.Value = pageNumber;
       param.DbType = DbType.Int32;
       comm.Parameters.Add(param);


       //cria um novo parametro
       param = comm.CreateParameter();
       param.ParameterName = "@ProdutosPorPagina";
       param.Value = TendenciasConfigurations.ProdutosPorPagina;
       param.DbType = DbType.Int32;
       comm.Parameters.Add(param);


       //cria um novo parametro
       param = comm.CreateParameter();
       param.ParameterName = "@HowManyProducts";
       param.Direction = ParameterDirection.Output;
       param.DbType = DbType.Int32;
       comm.Parameters.Add(param);


       //executa a stored procedure e salva os resultados no datatable
       DataTable tabela = GenericDataAcess.ExecuteSelectCommand(comm);
       //calcula quantas paginas por produtos e define o parametro de saida
       int howmanyProducts = Int32.Parse(comm.Parameters["@HowManyProducts"].Value.ToString());
       howManyPages = (int)Math.Ceiling((double)howmanyProducts / (double)TendenciasConfigurations.ProdutosPorPagina);

       //retorna a pagina dos produtos
       return tabela;
   } 
    
asked by anonymous 01.03.2016 / 12:01

1 answer

0

Depending on what you want to do, you can use ajax request, ie in your tag you would have the onclick html event that would call a javascript function, which would eventually call your c # method through a service.

It would look something like this:

Page:

<map name="Cores">
    <area shape="rect" alt="Rosa" coords="8,8,96,116" onclick="teste('<%= valor1 %>');">
</map>

// Note: value1 is a variable I created in C #, use yours. Remembering that it must be public, you can also access a method that returns something instead of the variable. Example

10.03.2016 / 17:44