I want to use C# code and JavaScript in the same onclientclick
event.
<asp:Link开发者_如何学PythonButton ID="lbTest" runat="server" Text='<%#Text%>'
OnClientClick='<%#string.Format("passAccessory(\"{0}\");", Eval("Ref"))%>; window.close();' />
But it doesn't work. How to do that?
Thanks.
What are you reying to acheive? Do you wnat to call a javascript function which uses some of server side variables and close at the end.
function MyF()
{
var myvar = '<%= myC#Var %>';
....do something
window.close()
}
<asp:LinkButton ID="lbTest" runat="server" OnClientClick='MyF()' />
add an OnClientClick and OnClick events. The OnClientClick event will be executed first then the OnClick event.
<asp:LinkButton ID="lbTest" runat="server" OnClientClick="test()" OnClick="lbTest_Click" />
精彩评论