sudha
sudha

Reputation: 21

how to Call cs function from html button

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

Answers (2)

wassertim
wassertim

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

Fabian
Fabian

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

Related Questions