从HTML按钮控件调用服务器端事件 [英] calling server side event from html button control
问题描述
我创建使用ASP.Net应用程序,其中我有aspx页面上的HTML按钮。
I am creating an application using ASP.Net, in which I have an HTML button on aspx page.
<input type="submit" id="btnSubmit" runat="server"
style="background-image:url(App_Themes/default/Images/quiz_class/btn_submit.jpg);
width:80px; height:29px;" onserverclick="btnSubmit_ServerClick" />
但是,当我点击按钮,然后它不aspx.cs页面上调用btnSubmit_ServerClick事件。
But when I click on the button then it not calling the btnSubmit_ServerClick event on aspx.cs page.
我不想用asp控制按钮。
I don't want to use asp control button.
请帮助..
推荐答案
如果你是通过指定 =服务器
,并且正在使用 asp.net
,选项可以使用HtmlButton.OnServerClick属性。
If you are OK with converting the input button to a server side control by specifying runat="server"
, and you are using asp.net
, an option could be using the HtmlButton.OnServerClick property.
<input id="foo "runat="server" type="button" onserverclick="foo_OnClick" />
这应该工作,并调用 foo_OnClick
在你的服务器端code。
还要注意,根据上面链接Microsoft文档,你也应该能够使用HTML标记4.0
This should work and call foo_OnClick
in your server side code.
Also notice that based on Microsoft documentation linked above, you should also be able to use the HTML 4.0 tag.
这篇关于从HTML按钮控件调用服务器端事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!