asp:下拉列表
以下代码有效,但验证失败时下拉列表未返回其原始值有什么想法吗?
<tr><td valign="top" style="padding-right: 10px;">
<b>Select Account:</b>
<asp:DropDownList ID="m_lstAccounts" runat="server" CausesValidation="true" ValidationGroup="Group1"
CssClass="dropdownList" OnSelectedIndexChanged="OnAccountChange" AutoPostBack="True"></asp:DropDownList>
<br />
<script type="text/javascript">
function ConfirmDropDownValueChange(source, arguments) {
if (document.all("AccountProfileDirty").value == "1") {
arguments.IsValid = confirm("Are you sure you want to continue with out saving?");
source.
}
else {
arguments.IsValid = true;
}
}
</script>
<asp:CustomValidator ID="ConfirmDropDownValidator" runat="server"
ClientValidationFunction="ConfirmDropDownValueChange" Display="Dynamic" ValidationGroup="Group1" /> </td> </tr>
The following code works except the dropdown list is not returned to its original value when the validation fails any ideas?
<tr><td valign="top" style="padding-right: 10px;">
<b>Select Account:</b>
<asp:DropDownList ID="m_lstAccounts" runat="server" CausesValidation="true" ValidationGroup="Group1"
CssClass="dropdownList" OnSelectedIndexChanged="OnAccountChange" AutoPostBack="True"></asp:DropDownList>
<br />
<script type="text/javascript">
function ConfirmDropDownValueChange(source, arguments) {
if (document.all("AccountProfileDirty").value == "1") {
arguments.IsValid = confirm("Are you sure you want to continue with out saving?");
source.
}
else {
arguments.IsValid = true;
}
}
</script>
<asp:CustomValidator ID="ConfirmDropDownValidator" runat="server"
ClientValidationFunction="ConfirmDropDownValueChange" Display="Dynamic" ValidationGroup="Group1" /> </td> </tr>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的ConfirmDropDownValueChange() 函数中间的随机
source.
是什么?那肯定会让 JavaScript 失败。What is the random
source.
in the middle of your ConfirmDropDownValueChange() function? That would certainly make JavaScript fail.