Two parameters with String.Format in an asp: HyperLink

3

I would like to send the parameters (ID of the database, ClientID) to a <asp:Hyperlink . I wanted the final result to be:

<a id="ctl00" onclick="OpenModal(704520,'asdf_ID_DaImageAbaixo')">
    <img id="ID_IMAGE" src="../online/img_admin/icon_hist.gif" />
</a>

But I can not do 2 things. First the single quotation marks is not working.

String.Format("AbreModal({0},'{1}')",

Give Unformatted tag with these single quotes. Without them it works, but then it does not close in JavaScript.

Second: I can not capture the image ID below and send this link, I'm trying:

<asp:HyperLink ID="HyperLink4" runat="server" onclick='<%# String.Format("AbreModal({0},{1})", DataBinder.Eval(Container.DataItem, "intid"),"123" ) %>'>
 <asp:Image ID="img_Historico" runat="server" ImageUrl="../online/img_admin/icon_hist_off.png" />
</asp:HyperLink>

How to submit?

    
asked by anonymous 13.03.2014 / 16:43

2 answers

1

Try something like this:

<asp:HyperLink ID="HyperLink4" runat="server" onclick="<%# String.Format("AbreModal({0},\"{1}\"",val1,val2) %>">
   <asp:Image ID="img_Historico" runat="server" ImageUrl="../online/img_admin/icon_hist_off.png" />
</asp:HyperLink>

Replacing val1 with your DataBind and val2 with ID value

    
13.03.2014 / 17:58
-2

Have you tried?

onclick='AbreModal(<%#DataBinder.Eval(Container.DataItem, "intid")%>, "123" )'
    
25.03.2014 / 17:18