Question

i drag a linkbutton into my masterpage and i try to run it , it says i should put a form tag runat = server , after i put it , it says that i can only have 1 form tag , but i check my materpage , don't have any form tag ..

<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Logout</asp:LinkButton>

My other pages have form tag of runat = server because when i try it , they told me to add it in , What have i done wrong and how should i correct it

My full master page : enter image description here

enter image description here

Was it helpful?

Solution

Master pages are are also webforms, except that it will combine with content pages to form a single page at runtime. You'll need to put any server control inside <form runat="server"></form> . After you've made this, you don't need to add tags on other pages which is content page of this master page.

As of now, you can solve your problem by adding a

<form runat="server">
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Logout</asp:LinkButton>
</form>

Put the ContentPlaceholder control inside the form tag

Remove <form> tag from content page

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top