0

I just created an ASP.NET, C# web application and for the first time i used a master page.

I learnt that you can't have two forms that runat "server" because it causes an error, so for the form (which uses for login) at the top of the master page i used a runat="server" and for a form in the content page i removed the runat attribute.

Now i cannot use the 'defaultbutton' attribute and the "Enter" key will go to the login button at the master page even if a text field in the content page is now active.

What is the solution to this problem? Thanks!

argamanza
  • 1,122
  • 3
  • 14
  • 36
  • Indeed, you can't have 2 forms on a page. You'll probably want to rethink your use of the master page, as normally it's just for holding data that's repeated across multiple pages (for example, a navigation menu) and then has a content template for the page specific content, having actual form data there doesn't normally make sense. – user2366842 Apr 10 '15 at 15:56
  • @user2366842 - so if i want a login area, do i need to add another content place holder? – argamanza Apr 10 '15 at 19:28

1 Answers1

1

You can use multiple Panel controls for this.

<asp:Panel ID="SearchBox" runat="server" DefaultButton="BtnSearch">
    ...
    <asp:Button ID="BtnSearch" runat="server" Text="Search!" />
</asp:Panel>
....
<asp:Panel ID="UserPanel" runat="server" DefaultButton="BtnUserSubmit">
    ...
    <asp:Button ID="BtnUserSubmit" runat="server" Text="Submit" />
</asp:Panel>

how to set a default 'enter' on a certain button

Community
  • 1
  • 1
Seventh Son
  • 131
  • 6