ASP.NET/HTML:里面ASP.NET HTML按钮的onClick属性(的.cs) [英] ASP.NET/HTML: HTML button's onClick property inside ASP.NET (.cs)

查看:93
本文介绍了ASP.NET/HTML:里面ASP.NET HTML按钮的onClick属性(的.cs)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想看看是否有把我的onClick事件里面的.cs方式:

I just wanna find out if there's a way to put my onClick event inside .cs:

<button type="submit" runat="server" id="btnLogin" class="button" onclick="btnLogin_Click();">

其中Login_Click()应该是里面的.cs:

where Login_Click() should be inside .cs:

protected void btnLogin_Click(object sender, EventArgs e)
{
    // do something
} 

请不要拿注意,我在这里不使用ASP.NET按钮,我不会把我的Login_Click()事件中的.html /的.aspx所以我不能'暴露'我的代码。有什么建议?

Please do take note that I will not use ASP.NET button here, and that I will not put my Login_Click() event inside .html/.aspx so I can't 'expose' my codes. Any suggestions?

推荐答案

您可以做到这一点在任何服务器控件此按钮被定义做了一个服务器控件 RUNAT =服务器。这个问题可能是在你的事件的定义:

You can do that on any server control and this button is made a server control by defining "runat=server". The problem is probably in your definition of the event:

<button ... runat="server" ... onServerClick="btnLogin_Click" />

您不需要(); 有...

除此之外,你能解释一下你为什么不使用< ASP:按钮> 这里,因为我真的不觉得这有一个问题...

Apart from that can you explain why you don't use the <asp:Button> here because I don't really see a problem with that...

这篇关于ASP.NET/HTML:里面ASP.NET HTML按钮的onClick属性(的.cs)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆