OnServerClick not working

不羁的心 提交于 2019-12-13 19:48:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!