Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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();">

where Login_Click() should be inside .cs:

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
116 views
Welcome To Ask or Share your Answers For Others

1 Answer

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" />

You don't need "();" there...

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...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...