为什么我的asp更新面板只刷新一次
本文关键字:一次 刷新 asp 我的 更新 为什么 | 更新日期: 2023-09-27 18:02:17
嗨,我有一个asp updatePanel,其中包含几个asp面板。它的功能是你点击第一个面板上的按钮,它会隐藏那个面板并显示下一个面板。这很好,问题出在下一个面板上。如果我尝试使用面板中的任何一个按钮控件,什么也不会发生。
html
<asp:UpdatePanel runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:Panel ID="pnlAppRej" runat="server" HorizontalAlign="Center" CssClass="textBox"
Width="85%" Visible="True">
<div style="text-align:left; width:90%">
<asp:Label ID="lblAppRej" runat="server" Text="Label"></asp:Label>
</div>
<asp:Button ID="btnApprove" runat="server" Text="Approve" CssClass="button" Style="margin-right: 20px;
margin-top: 10px" Width="100px" onclick="btnApprove_Click" />
<asp:Button ID="btnReject" runat="server" CssClass="button" Text="Reject" Style="margin-left: 20px"
Width="100px" onclick="btnReject_Click" />
</asp:Panel>
<asp:Panel runat="server" ID="pnlRejCom" Width="85%" Visible="False" CssClass="textBox">
<div style="text-align: left">
Comments<br />
</div>
<asp:TextBox ID="tbRejCom" runat="server" Height="54px" TextMode="MultiLine" Width="95%"
CssClass="textBox" Style="margin-top: 5px" ValidationGroup="rejCom"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="tbRejCom"
ErrorMessage="RequiredFieldValidator" ValidationGroup="rejCom">*</asp:RequiredFieldValidator>
<br />
<div style="text-align: center">
<asp:Button ID="btnBackRejCom" runat="server" CssClass="button" Text="Back" Style="margin-right: 20px;
margin-top: 10px" Width="100px" />
<asp:Button ID="btnDoneRejCom" runat="server" CssClass="button" Text="Done" Style="margin-left: 20px;
margin-top: 10px" Width="100px" ValidationGroup="rejCom"
onclick="btnDoneRejCom_Click" />
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
c#代码 protected void btnReject_Click(object sender, EventArgs e)
{
pnlRejCom.Visible = true;
pnlAppRej.Visible = false;
}
protected void btnBackRejCom_Click(object sender, EventArgs e)
{
pnlRejCom.Visible = false;
pnlAppRej.Visible = true;
}
它的btnBackRejCom_Click方法似乎不触发。但是我已经测试了将pnlRejCom设置为可见,该方法工作得很好。
Thanks in advance
查理你的问题似乎不一样。我建议,删掉
protected void btnBackRejCom_Click(object sender, EventArgs e){}
并再次创建一个新事件。
这是我试过的,现在工作得很好。
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="btnReject" />
<asp:AsyncPostBackTrigger ControlID="btnBackRejCom" />
<asp:PostBackTrigger ControlID="btnDoneRejCom" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="pnlAppRej" runat="server" HorizontalAlign="Center" CssClass="textBox"
Width="85%" Visible="True">
<div style="text-align: left; width: 90%">
<asp:Label ID="lblAppRej" runat="server" Text="Label"></asp:Label>
</div>
<asp:Button ID="btnApprove" runat="server" Text="Approve" CssClass="button" Style="margin-right: 20px; margin-top: 10px"
Width="100px" OnClick="btnApprove_Click" />
<asp:Button ID="btnReject" runat="server" CssClass="button" Text="Reject" Style="margin-left: 20px"
Width="100px" OnClick="btnReject_Click" />
</asp:Panel>
<asp:Panel runat="server" ID="pnlRejCom" Width="85%" Visible="False" CssClass="textBox">
<div style="text-align: left">
Comments<br />
</div>
<asp:TextBox ID="tbRejCom" runat="server" Height="54px" TextMode="MultiLine" Width="95%"
CssClass="textBox" Style="margin-top: 5px" ValidationGroup="rejCom"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="tbRejCom"
ErrorMessage="RequiredFieldValidator" ValidationGroup="rejCom">*</asp:RequiredFieldValidator>
<br />
<div style="text-align: center">
<asp:Button ID="btnBackRejCom" runat="server" CssClass="button" Text="Back" Style="margin-right: 20px; margin-top: 10px"
Width="100px" OnClick="btnBackRejCom_Click1" />
<asp:Button ID="btnDoneRejCom" runat="server" CssClass="button" Text="Done" Style="margin-left: 20px; margin-top: 10px"
Width="100px" ValidationGroup="rejCom"
OnClick="btnDoneRejCom_Click" />
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
背后代码:
protected void btnBackRejCom_Click1(object sender, EventArgs e)
{
pnlRejCom.Visible = false;
pnlAppRej.Visible = true;
}
希望这对你有帮助。编码. .快乐! !
我也有同样的问题,所以我刚刚添加了CausesValidation="False",然后它对我来说很好。所以请在btnBackRejCom按钮中添加CausesValidation,如下所示
Please try it
<asp:Button ID="btnBackRejCom" runat="server" CausesValidation="False" CssClass="button" Text="Back" Style="margin-right: 20px;
margin-top: 10px" Width="100px" />
我想这对你有用