0

I have used more than one Button in a Master page. Also there is a button in my login page. The problem is while submitting the content of login page with login button , it works but when in login page i clik Home button(Master page buttons) , it doesn't work, it works as a submitting button .

My Master page code :

<body style="margin:0px;">
<form id="form1" runat="server">
<div>
    <div class="auto-style1" style="background-color: #3399FF; height: 42px;">
        <asp:Button ID="homeButton" runat="server" CssClass="auto-style2" Text="Home" Width="126px" BorderStyle="None" BackColor="#3366FF" Height="42px" OnClick="homeButton_Click" />
        <asp:Button ID="newsButton" runat="server" CssClass="auto-style3" Text="News" Width="127px" BorderStyle="None" BackColor="#3366FF" Height="42px" OnClick="newsButton_Click" />
        <asp:Button runat="server" CssClass="auto-style4" Text="Shared Files" Width="123px" BorderStyle="None" BackColor="#3366FF" Height="42px" OnClick="Unnamed1_Click" />
        <asp:Button ID="memberButton" runat="server" CssClass="auto-style5" Text="Members" Width="117px" BorderStyle="None" BackColor="#3366FF" Height="42px" OnClick="memberButton_Click" />
        <asp:Button ID="blogButton" runat="server" CssClass="auto-style6" Text="Blogs" Width="103px" BorderStyle="None" BackColor="#3366FF" Height="42px" OnClick="blogButton_Click" />

        <asp:Button ID="loginButton" runat="server" BackColor="#3366FF" BorderStyle="None" CssClass="auto-style8" Height="42px" Text="Log in" Width="82px" OnClick="loginButton_Click" />
        <asp:Button ID="Button1" runat="server" BackColor="#3366FF" BorderStyle="None" CssClass="auto-style9" Height="42px" Text="Register" Width="96px" OnClick="Button1_Click" />

    </div>
    <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

    </asp:ContentPlaceHolder>

</div>
</form>

And My Master Page code Behind is :

protected void homeButton_Click(object sender, EventArgs e)
{
   Response.RedirectPermanent("Home.aspx");
}
protected void newsButton_Click(object sender, EventArgs e)
{
    Response.RedirectPermanent("News.aspx");
}
protected void Unnamed1_Click(object sender, EventArgs e)
{
    Response.RedirectPermanent("Shared_Files.aspx");
}
protected void memberButton_Click(object sender, EventArgs e)
{
    Response.RedirectPermanent("Members.aspx");
}
protected void blogButton_Click(object sender, EventArgs e)
{
    Response.RedirectPermanent("Blogs.aspx");
}
protected void loginButton_Click(object sender, EventArgs e)
{
    Response.RedirectPermanent("Login.aspx");
}
protected void Button1_Click(object sender, EventArgs e)
{
    Response.RedirectPermanent("Register.aspx");
}
ps2goat
  • 8,067
  • 1
  • 35
  • 68
sunkuet02
  • 2,376
  • 1
  • 26
  • 33
  • 2
    You can have as many buttons as you want. Define "doesn't work." What *does* it do? Is the server-side handler method invoked? What does that handler do? Does something in `Page_Load` interrupt the logic? – David Mar 01 '14 at 14:29
  • 1
    its not very clear, try to make your question more understandable – meda Mar 01 '14 at 14:33
  • If you don't want it to act as a submit button, check this post - http://stackoverflow.com/questions/4608921/asp-button-with-different-button-type – aw04 Mar 01 '14 at 14:33
  • please show me your master page server side code? – Ramesh Rajendran Mar 01 '14 at 14:36
  • Ramesh Rajendran , I have edited my code – sunkuet02 Mar 01 '14 at 14:42

2 Answers2

0

You problem in body of ClickEventHandlers. You use RedirectPermanent method.
From msdn:

The RedirectPermanent(String) method overload provides a 301 HTTP status code in the response and includes the URL to redirect the request to. A 301 HTTP status code is a standard code in an HTTP response. It indicates that a permanent redirection exists, and it provides the redirection location.

Calling the RedirectPermanent(String) method overload terminates the response.

So you need use simple Redirect instead

Community
  • 1
  • 1
Grundy
  • 13,356
  • 3
  • 35
  • 55
0

Menu Control in Master page is advisable instead of using button control for Navigation between the pages

Jegadeesh
  • 335
  • 2
  • 16
  • Yes , When I have failed to use button I use text link,Then I have succeeded. – sunkuet02 Mar 03 '14 at 16:48
  • Menu control is always better look and ease of access. especially for navigation. Once If you start use sitemap then you come to know about these things – Jegadeesh Mar 03 '14 at 16:55