【发布时间】:2023-03-26 09:25:02
【问题描述】:
我在更新面板中有一个按钮。当我点击按钮时,它不会点击服务器端点击方法。不知道发生了什么。下面是给你们的代码。任何关于可能发生的事情的见解都会非常有帮助。按钮的 ID 是 btnPost。它是下方更新面板的一部分。
<asp:UpdatePanel ID="atlaspnlpost" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnlPost" runat="server" Style="width: 855px" GroupingText="Accounting use only">
<table class="MainSectionBody" style="width: 855px">
<tr style="height: 30px">
<td style="width: 165px">
<asp:Label ID="Label4" runat="server" Text="Accounting Date" Width="160px"></asp:Label>
</td>
<td style="width: 200px">
<asp:TextBox ID="txtAcctDate" runat="server" Width="200px" TabIndex="13" Text="01/18/2018"></asp:TextBox>
</td>
<td style="width: 85px">
<a runat="server" id="lnkAcctDate" style="cursor: hand">
<asp:Image ID="Image2" runat="server" ImageUrl="~/Images/calendar_small.gif" TabIndex="98">
</asp:Image></a>
<asp:CompareValidator ID="cvAccDate" runat="server" ErrorMessage="Accounting Date is Required"
Operator="DataTypeCheck" SetFocusOnError="True" Type="Date" ControlToValidate="txtAcctDate">*</asp:CompareValidator>
</td>
<td style="width: 405px">
<asp:CheckBox ID="chkApprove" Text="Approved By Accounting" runat="server" TabIndex="14" />
</td>
</tr>
<tr style="height: 30px">
<td style="width: 165px">
<asp:Label ID="lblApprover" runat="server" Text="Approver Name" Width="160px"></asp:Label>
</td>
<td style="width: 200px">
<asp:TextBox ID="txtApprover" runat="server" Width="200px" SkinID="ReadOnlyTextBox"
ReadOnly="True" TabIndex="99"></asp:TextBox>
</td>
<td style="width: 85px">
<td style="width: 405px">
<%--<asp:Button ID="btnPost" runat="server" Text="Post" Width="76px" TabIndex="15" />--%>
</td>
</tr>
<tr style="height: 30px">
<td style="width: 165px">
<asp:Label ID="lblDescription" runat="server" Text="Description" Width="160px"></asp:Label>
</td>
<td style="width: 200px">
<asp:TextBox ID="txtdescription" runat="server" Width="200px" TabIndex="99"
TextMode="MultiLine"></asp:TextBox>
</td>
<td style="width: 85px">
<td style="width: 405px">
<%-- <asp:Button ID="btnPost" runat="server" Text="Post" Width="76px" TabIndex="15" />--%>
</td>
</tr>
<tr style="height: 30px">
<td style="width: 165px">
<asp:Label ID="lblFinanceexplanation" runat="server" Text="FinanceExpalnation" Width="160px"></asp:Label>
</td>
<td style="width: 200px">
<asp:TextBox ID="txtFinanceExplanation" runat="server" Width="200px" TabIndex="99"
TextMode="MultiLine"></asp:TextBox>
</td>
<td style="width: 85px">
<td style="width: 405px">
<asp:Button ID="btnPost" runat="server" Text="Post" Width="76px" TabIndex="15" />
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnRefresh" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="ddlYear" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
下面是按钮后退事件:-
Protected Sub btnPost_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPost.Click
Dim sErrMsg As String = String.Empty
If CStr(Session(Common.Session.UserName)) = String.Empty Then
Response.Redirect("~/ErrorInfo.aspx?mes=Your session has expired. Please search the deal again", False)
Else
If Not ValidatePost(sErrMsg) Then
Me.DispMessage(sErrMsg)
Else
Try
If ValidateandSaveGrid() = True Then
SaveHoldBackAloc()
SaveEmpAlloc()
SavePaymentLog()
ConfigureAfterPost()
getHoldbackHistory()
Else
Me.DispMessage("Invalid Data")
End If
Catch ex As Exception
End Try
End If
End If
End Sub
【问题讨论】:
-
尝试将按钮添加为更新面板的回发触发器?
<asp:PostBackTrigger ... -
我不知道您的代码是如何工作的,请记住 注释是客户端注释,而不是服务器端。如果不是,那你页面里有
AutoEventWireup="true"这个属性吗? -
@hardkoded - 查看评论下方的几行。 btnPost 按钮未注释。我还查看了 AutoEventWireup。它设置为 false。
标签: asp.net vb.net asp.net-ajax