Breaking News

Editors Picks

Monday, December 26, 2011

Setting the default Button for a TextBox in ASP.NET


JavaScript function
function clickButton(e, buttonid)
{
var evt = e ? e : window.event;
var bt = document.getElementById(buttonid);
if (bt)
{
if (evt.keyCode == 13)
{
bt.click();
return false;
}
}
}

Call on button
<asp:ImageButton ID="ImageButton1" runat="server" Height="50" Width="50" BorderWidth="1"
CssClass="btnimage" ImageUrl="" OnClick="ImageButton1_Click" />
<input name="TextBox1" type="text" id="TextBox1" onkeypress="return clickButton(event,'ImageButton1')"  />

No comments :

Post a Comment

Contact Us

Name

Email *

Message *