user3731323
user3731323

Reputation: 3

Unable to call server side method in asp.net

I am working in asp.net. I have this HTML tag

HTML tag:

<button id="submit" class="button" onserverclick="delete_Click">Login</button>

Serverside Function:

 Response.Redirect("Login.aspx");

When I click the button it should go to Login.aspx page. But button is not working. Where am I mistaking?

Upvotes: 0

Views: 74

Answers (2)

Satwik Nadkarny
Satwik Nadkarny

Reputation: 5135

You need to add:

runat="server"

to the html tag.

Also, you need to make use of the OnClick event handler.

In essence, you tag should look like this:

<asp:Button ID="submit" runat="server" class="button" OnClick="delete_Click">Delete</asp:Button>

Hope this helps!!!

Upvotes: 0

Sachin
Sachin

Reputation: 40970

Use OnClick instead of onserverclick and better to use ASP.NET control if you are achieving this

<asp:Button ID="submit" runat="server" CssClass="button" OnClick="delete_Click">Login</asp:Button>

Upvotes: 3

Related Questions