【发布时间】:2015-10-22 07:49:43
【问题描述】:
我不擅长 jquery,如果用户在 RadioButtonList 路径中选择 Yes(1),我试图阻止 .net 表单提交。下面是我的代码,我不知道为什么它不起作用。
当我运行 .net 应用程序时,表单名称变为 aspnetform,而 radPathway RadioButtonList 变为 #ctl00$ContentPlaceHolder1$radPathway:
<script>
$('#aspnetForm').submit(function () {
if ($('#ctl00$ContentPlaceHolder1$radPathway').val() === "1") {
alert('Stop!');
return false;
}
});
</script>
.aspx 代码:
<p>
<asp:Label ID="Label23" runat="server" Font-Bold="True"
Text="Pathway member?"></asp:Label>
<asp:RadioButtonList ID="radPathway" runat="server" RepeatDirection="Horizontal" Width="50px">
<asp:ListItem Value="1">Yes</asp:ListItem>
<asp:ListItem Value="0">No</asp:ListItem>
</asp:RadioButtonList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator17" runat="server"
ControlToValidate="radPathway" ErrorMessage="Please select your pathway status" ForeColor="red">
</asp:RequiredFieldValidator>
<asp:Label ID="lblpathway" runat="server" ForeColor="Red" Text="Label" Visible="False"></asp:Label>
</p>
【问题讨论】:
标签: c# jquery asp.net webforms