Reputation: 233
I have created a HTML Image button in a web application with an onclick
event handler. But the event is not firing. I am using the code below to create a button and its onclick
event handler.
<input type="image" runat="server" src="Plan_search/images/buy.png" onclick="goto_click" />
protected void goto_click(object sender, EventArgs e)
{
try
{
}
catch(Exception e1)
{
throw;
}
}
Upvotes: 2
Views: 5905
Reputation: 2000
This is working code.Use this..
<input type="image" runat="server" src="Plan_search/images/buy.png" onserverclick="goto_click" />
protected void goto_click(object sender, EventArgs e)
{
try
{
}
catch(Exception e1)
{
throw;
}
}
Upvotes: 2
Reputation: 17614
As @samjudson suggested.
It should be
<input id="Image1" type="image" runat="server" onserverclick="goto_click" />
But I think it should be using ImageButton
rather than image
Upvotes: 0
Reputation: 56853
I suspect you want to use the OnServerClick attribute, rather than OnClick.
Upvotes: 2
Reputation: 9002
You shouldn't create your button like input
element.
Create your button like ASP.NET
control:
<asp:ImageButton id="imagebutton1" runat="server"
ImageUrl="Plan_search/images/buy.png"
OnClick="goto_click"/>
Upvotes: 0
Reputation: 7549
You need parentheses:
goto_click()
And probably some arguments too.
Upvotes: -2