I have a dialog box that boxes that allows the user to do enter some texts in before submitting to server. The text is mandatory.
My code looks like this
This is the Jquery code to open up the dialog
function onReportThis() {
$("#dialog-Report").dialog({
resizable: false,
modal: true,
width: '400px',
buttons: {
Submit: function () {
__doPostBack('<%= lnkReportThis.UniqueID %>', '');
// onReported();
},
Cancel: function () {
$(this).dialog("close");
}
}
});
$("#dialog-Report").parent().appendTo(jQuery("form:first"));
return false;
}
This is the code for the box itself.
<div id="dialog-Report" style="display: none" title="Report This Profile">
<p>
I am reporting this profile because</p>
<asp:RequiredFieldValidator ID="validReportText" ControlToValidate="txtReportDetail" runat="server" ErrorMessage="Please enter text" ></asp:RequiredFieldValidator>
<p>
Please enter additional details regarding why you are reporting this profile</p>
<asp:TextBox ID="txtReportDetail" runat="server" Width="300px" Height="300px" TextMode="MultiLine" />
</div>
The required field validator is not being used before the callback. How do I get this to work? Thank you
开发者_C百科UPDATE : I've got it working.
I had to do this.
if (Page_ClientValidate()) {
__doPostBack('<%= lnkReportThis.UniqueID %>', '');
}
My friend, you are in a world of hurt... but to answer your question, you need to manually fire the validation events before you call the __dosubmit()
method.
This article explains how you can do this client side: http://fczaja.blogspot.com/2009/07/aspnet-how-to-trigger-client-side.html
Essentially, you want to call Page_ClientValidate();
before you submit
精彩评论