I have been working on Web Forms for many months, but today I encountered a problem.
I have e.g. 2 buttons on form Save
. Next, when a user fills out the form and presses Enter, it should trigger the SAVE button.
I tried a lot like
this.Page.Form.DefaultButton = btnSave.UniqueID;
this.Page.Form.DefaultFocus = btnSave.ClientID;
but it didn't work.
Please help me on this. I have tried many codes, but none of them actually worked.
protected void Page_Load(object sender, EventArgs e)
{
// 2 lines of code, for setting Save as a default
// button upon page loading so hitting Enter will
// trigger SAVE button.
this.Page.Form.DefaultButton = btnSave.UniqueID;
this.Page.Form.DefaultFocus = btnSave.ClientID;
if (Session.Count <= 0)
{
Response.Redirect("login.aspx");
}
lblMsgPopUp.Visible = false;
}