Reputation: 21
Html Button
<input id="Button1" type="button" value="button" runat="server"/>
.cs file:
public void display()
{
Response.Redirect("default.aspx");
}
How to call the display function which is in .cs file from html button click
Upvotes: 0
Views: 3782
Reputation: 3136
In your codebehind file use the following:
protected void Page_PreInit(object sender, EventArgs e)
{
Button1.ServerClick += display;
}
And change your display method signature to:
private void display(object sender, EventArgs e)
{
Response.Redirect("default.aspx");
}
Upvotes: 0
Reputation: 13691
Use a <asp:button>
instead and just bind the click event in the designer.
This will generate an input in the actual html.
Upvotes: 1