问题
The event is simply not firing, what am I missing?
Code for the button:
<input type="button" class="button hide" id="savetext" style="float:right;" value="Hello" runat="server" OnServerClick="savetext_Click"/>
and the code that is generated (ie. when opened in a browser and the source is viewed) is this:
<input onclick="__doPostBack('ctl00$Main$savetext','')" name="ctl00$Main$savetext" type="button" id="savetext" style="float:right;" class="button hide" value="Save to text" />
I've got <pages clientIDMode="Static" />
in web.config
but the name and generated onclick event are prefixed despite that.
Server side code:
Protected Sub savetext_Click(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
To be clear, my goal is to register a click on a button server-side, not just client-side. Thanks.
回答1:
Maybe a javascript error stop it from running...
Well I say that because they only reason that is stop it from working, from the code I see was the javascript error.
来源:https://stackoverflow.com/questions/4608733/onserverclick-not-working