Reputation: 10628
I'm trying to call the MyJavascriptFunction(arg1) from an asp button and it's doesn't work...
<asp:Button ID="btnMyButton" runat="server"
OnClientClick='<%# Eval("Id", "MyJavascriptFunction({0})") %>' />
The html generated contains no OnClick event at all.
Upvotes: 0
Views: 2470
Reputation: 21
This is when you are doin in listview or data grid
<asp:button id="ButtonDownload" runat="server" Text="Download"
OnClientClick='<%# String.Format("return downloadFile(\"{0}\")",Eval("QueryID")) %>' />
Upvotes: 2
Reputation: 25369
This is untested, and might not work or it will need more escaping. but try something like:
<asp:Button ID="btnMyButton" runat="server"
OnClientClick='<%# String.Format("MyJavascriptFunction(\"{0}\"", this.ClientID) %>' />
Note you need to use ClientID (rather than ID) to get the actual ID rendered in the HTML for your button.
Upvotes: 0
Reputation: 81831
Could you write this method in your Page_Load event
Page.Databind();
and this button is under another data control ?
Upvotes: 0