我有一个表单,显示一个 asp.net 网格,网格中列出了不同的人。
用户可以通过单击页面上的 asp.net 按钮将新用户添加到网格中:
单击此按钮时,将打开一个 JQuery 对话框:
$(document).ready(function() {
$('#content_button #ctl00_MainContent_btnAddPerson').each(function() {
var $link = $(this);
var $dialog = $('<div></div>')
.load($link.attr('title') + ' #content_dialogBox')
.dialog({
autoOpen: false,
title: $link.attr('value'),
width: 500,
beforeclose: function() { window.location = "ManagePeople.aspx" }
});
$link.click(function() {
$dialog.dialog('open');
return false;
});
});
});
这一切都工作正常。但是,对话框表单上的某些字段必须进行验证。起初,我使用了asp.net必填字段验证。由于某种原因,这不起作用。所以,我在代码隐藏中进行验证。验证有效(就像对所需字段控件所做的那样),但表单显示在它自己的窗口中,而不是在 JQuery 对话框中。有人可以告诉我我做错了什么吗?
注意:ManagePeople.aspx 是包含网格的页面。单击 addperson 按钮后,将显示 AddPerson.aspx 中 #content_dialogBox 的内容。
I have a form that displays an asp.net grid with different people listed in the grid.
A user can add new user's to the grid, by clicking an asp.net button on the page:
<div id="content_button">
<asp:Button ID="btnAddperson" runat="server"
CssClass="content_button"
PostBackUrl="addperson.aspx" Text="Add
Person"
ToolTip="addPerson.aspx" />
</div>
When this button is clicked, a JQuery dialog is opens:
$(document).ready(function() {
$('#content_button #ctl00_MainContent_btnAddPerson').each(function() {
var $link = $(this);
var $dialog = $('<div></div>')
.load($link.attr('title') + ' #content_dialogBox')
.dialog({
autoOpen: false,
title: $link.attr('value'),
width: 500,
beforeclose: function() { window.location = "ManagePeople.aspx" }
});
$link.click(function() {
$dialog.dialog('open');
return false;
});
});
});
This all works fine. However, there are some fields on the dialog form that have to be validated. At first, I used asp.net required field validation. For some reason, that didn't work. So, I am validating in the code-behind. The validation works (as it did with the required field controls), but the form displays in it's own window, instead of within the JQuery dialog. Can someone please tell me what I'm doing wrong.
Note: ManagePeople.aspx is the page that contains the grid. Once the addperson button is clicked the contents of the #content_dialogBox in the AddPerson.aspx is displayed.
发布评论
评论(1)
您是否尝试过使用 JQuery Validation 插件进行客户端验证?另外,您使用什么进行服务器端验证。我希望它是 FluentValidation。它让您的生活变得非常轻松。
http://docs.jquery.com/Plugins/Validation
Have you tried using the JQuery Validation plugin for client side validation? Also, what are you using for Server Side validation. I hope it is FluentValidation. It makes life very easy for you.
http://docs.jquery.com/Plugins/Validation