在按钮单击-Button事件未触发时,Webform重定向到default.aspx

时间:2015-07-20 14:27:36

标签: c# html asp.net webforms

我有两个表单“default.aspx”,“Secondary.aspx”,这两个表单都在主页上运行。逻辑是这样的,在用户通过文本框回答一些问题并单击按钮后,default.aspx重定向到“Secondary.aspx”。

在被重定向到“Secondary.aspx”后,页面显示用户所做的所有条目,并且他们必须单击“确认”按钮,以便在“Secondary.aspx”上显示一个文本标签“You”完成!“,但是当点击”确认“按钮时,由于某种原因页面重定向到”default.aspx“

这是我的辅助按钮的html。

<asp:Button ID="Button1" runat="server"  Text="Confirm" OnClick="Button1_Click" />

这是它应该执行的功能

protected void Button1_Click(object sender, EventArgs e)
{
//Perform Logic then print label
SuccessLabel.Text = "You are done!"
}

在我开始使用masterpages之前,我只有“default.aspx”和“Secondary.aspx”。为了确保在按下按钮后,再次发布相同的页面,我使用下面的代码“Secondary.aspx”:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Secondary.aspx.cs" Inherits="PrototypeV1_2.Secondary" %>
<head>...</head>
<body>
<form id="form1" action="Secondary.aspx" method="post" runat="server">
..
</form>
<body>

添加action="Secondary.aspx" method="post"确保在按钮单击后,更新/刷新“secondary.aspx”以显示标签。

我现在怎样才能使用母版页,因为母版页我没有<form> </form>标签来抑制结果显示在同一页面上;但它看起来如下所示:

<asp:Content ID="Content3" ContentPlaceHolderID="contentBody" Runat="Server">

     <asp:Button ID="Button1" runat="server"  Text="Confirm" OnClick="Button1_Click" />

</asp:Content>

0 个答案:

没有答案