Setting default button by using panel
Here We have to discuss about how to set the default button in Masterpage
for ex: in Master i have Search_textbox and Search_button when the user enter some text in the Textbox and pres Enter so the Search_button should trigger..
Html Code <asp:Panel ID="SearchStyle_Panel" runat="server" width="100%"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="188" align="right" valign="middle" class="white_text"> SEARCH </td> <td width="235" align="right" valign="middle"> <asp:TextBox ID="search_textbox" runat="server" value="ENTER KEYWORD" onfocus="if (this.value == 'ENTER KEYWORD') {this.value = '';}" onblur="if (this.value == '') {this.value = 'ENTER KEYWORD';}" CssClass="textbox"></asp:TextBox> </td> <td width="5" align="right" valign="middle"> </td> <td width="40" align="right" valign="bottom"> <asp:Button ID="search_button" runat="server" Text="GO" CssClass="go_btn"/> </td> </tr> </table> </asp:Panel>
since the button is nested inside of a control that implememts INamingContainer, its UniqueId will not match its server ID
for that reason, you should set the DefaultButton property in code.
myPanel.DefaultButton = myButton.UniqueId
then on page_load
SearchStyle_Panel.DefaultButton = search_button.UniqueID
Read more »