我有一个ASP中继器,其中包含一些项目信息,一个接受按钮,一个取消按钮和一个取消原因文本框。我希望取消按钮验证取消中是否有一些文本(如果没有弹出,则显示“您需要输入原因”)。我希望接受按钮仅在页面上提交项目。这是我的尝试,但是该函数不想找到(绑定)txtReason
<asp:UpdatePanel runat="server" ID="updatePanelAcceptOrReject">
<ContentTemplate>
<asp:Repeater runat="server" ID="AcceptOrRejectRepeater" OnItemDataBound="AcceptOrRejectRepeater_ItemDataBound">
<ItemTemplate>
<asp:Label ID="lblDescription" runat="server" Text='<%# Bind("ItemDescription")%>'></asp:Label
<asp:Label ID="lblReasonForCancelling" runat="server" Text="Reason for rejection"></asp:Label>
<asp:TextBox runat="server" ID="txtReason"></asp:TextBox>
<script type="text/javascript">
function fnCheckforCancelReason() {
var pgng = document.getElementById('<%=txtReason.ClientID%>').value.trim();
if (pgnd == "") {
alert('The textbox should not be empty...');
document.getElementById(txtReason).focus();
return false;
}
}
</script>
<asp:Button ID="btnReject" runat="server" Text="Reject" CommandArgument='<%# Bind("ItemID") %>' OnClientClick="javascript:return fnCheckforCancelReason()" OnClick="btnReject_Click" />
<asp:Button ID="btnAccept" runat="server" Text="Accept" CommandArgument='<%# Bind("ItemID") %>' OnClick="btnAccept_Click" />
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
但是该函数不想找到(绑定)txtReason,并且我无法设置断点(计时或ie)
我希望能够插入一个断点来调试fnCheckforCancelReason
最佳答案
pgng上的错字:
var pgng = document.getElementById(...
if (pgnd == "") {