Monday, May 12, 2025

Breaking News
>> Securing and encrypt View State and Cookies values  >> Page has one or more controls that do not correspond with   >> “The Controls collection cannot be modified because the control contains code blocks”  >> How to fix "Validation(): Element 'xxxx' is not supported  >> How to create a new session in ASP.NET programmatically  >> MySQL Database Backup using mysqldump command    

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 *