"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Friday, November 4, 2011

Default button and Default Focus

HI *.*,
Default button property is used to specify which button gets clicked when "ENTER" key is pressed.
and Default Focus  property is used to get focus on that control on page start-up(Just like Gmail login,Focus on Username text box and when enter button is clicked login,if valid :P )


<form id="form1" runat="server" defaultbutton="cmdSubmit" defaultfocus="txtUser">
<asp:Panel runat="server" ID="Panel1" DefaultButton="cmdSubmit"></asp:Panel>
 If you are using MasterPages,

    (Page.Master.FindControl("Form1") as HtmlForm).DefaultButton = this.cmdSubmit.UniqueID;
or
Page.Master.Page.Form.DefaultButton = cmdSubmit.UniqueID;
 If u had any trouble just ask, Happy to help u :) 
Stay Tune... 
Have a nice day... 'N happy Coding :)

No comments: