Two parameters with String.Format in an Asp:Hyperlink

Asked

Viewed 485 times

3

I would like to send the parameters (database ID, Clientid) in a <asp:Hyperlink. I wanted the end 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’t do 2 things. First the simple quotes are not working.

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

Gives Tag not formatted with these simple quotes. Without them it works, but then does not close in Javascript.

Second: I can’t 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 send?

  • Any personal suggestions?

2 answers

1


Try something like that:

<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 its Databind and val2 with the ID value

  • It didn’t work, with your code the result was: onclick="AbreModal(704520,&quot;123&quot;) and the most important detail is that I can’t get past the ClientID of the image below this String.Format;

-2

Have you tried?

onclick='AbreModal(<%#DataBinder.Eval(Container.DataItem, "intid")%>, "123" )'
  • ?? the question is how to send in place of the 123 you put the ID of an image below ? he does not recover with Clientid, I tried for property and also did not give..

Browser other questions tagged

You are not signed in. Login or sign up in order to post.