2014-03-01 74 views
0

我在Master頁面中使用了多個Button。我的登錄頁面中還有一個按鈕。問題是提交登錄頁面的內容與登錄按鈕,它的作品,但在登錄頁面我clik主頁按鈕(母版頁按鈕),它不起作用,它作爲一個提交按鈕。我可以在網頁中使用多個ASP.NET按鈕嗎?

我的母版頁代碼:

<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> 

和我的母版頁後面的代碼是:

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"); 
} 
+2

只要你想你可以有很多按鈕之間。定義「不起作用」。它有什麼作用?服務器端處理程序方法是否被調用?那個處理程序是做什麼的? 'Page_Load'中有什麼中斷邏輯? – David

+1

它不是很清楚,試着讓你的問題更容易理解 – meda

+0

如果你不想讓它充當提交按鈕,請檢查這個帖子 - http://stackoverflow.com/questions/4608921/asp-button-with-不同按鈕類型 – aw04

回答

0

菜單控制是可取的,而不是使用按鍵控制導航的頁面

+0

是的,當我沒有使用按鈕時,我使用文本鏈接,然後我成功了。 – sunkuet02

+0

菜單控制總是更好看和易於訪問。尤其適用於導航。一次如果你開始使用網站地圖,那麼你會了解這些事情 – Jegadeesh

0

ClickEventHandlers身體,你的問題。您使用RedirectPermanent方法。
從MSDN:

的永久重定向(String)方法過載的響應提供了一個301的HTTP狀態代碼,幷包括的URL請求重定向到。 301 HTTP狀態碼是HTTP響應中的標準代碼。它表示存在永久重定向,並提供重定向位置。

調用RedirectPermanent(String)方法重載會終止響應。

所以你需要使用簡單的母版頁Redirect,而不是

相關問題