Link to home
Start Free TrialLog in
Avatar of maqskywalker
maqskywalker

asked on

C# server side click event for html button

On my page Default.aspx

I have a asp button like this:

<asp:Button ID="Button2" runat="server" Text="Button" />

On this page Default.aspx.cs

The server side click event for the button is this:

protected void Button2_Click(object sender, EventArgs e)
{

}

If I have a html button like this on this page Default.aspx

<input id="Button1" type="button" value="button" />

How do I call the Server-Side click event for it?
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If it is asp.net as your server side code suggests, then something like this:

<asp:Button ID="btn" runat="server" "onclick="Button2_Click" /> 

Open in new window


You were just mixing things up and that would not have done anything.

By the way, you may want to add some code to your button2_click() event to see what it returns when you click the button.
Avatar of maqskywalker
maqskywalker

ASKER

thanks
THis is the second time today I provided solution to someone but they accept a different solution.

That solution you accepted as right solution has invalid asp.net tags but good luck as I intend to avoid you next time.