javascript - Asp.net button event handler not working with validation? -
i can't seem know wouldn't work.
have button js
call open form in fancybox
modal fine.
i can validate data in form fine using asp.validation , throw messages in group div
if required.
when try submit form, doesn't anything.
<asp:textbox id="miemailtextbox" runat="server" text="email address" cssclass="miemailfieldtextbox"></asp:textbox><asp:button id="miemailfieldsubmitbutton" runat="server" text="submit" cssclass="buttonpositive" onclientclick="return nextclick()" />
js open fancybox opens contents of div.
function nextclick() { var emailaddress = $("[id$='_miemailtextbox']").val(); if (emailaddress != "email address" && emailaddress != "") { $("[id$='email']").val(emailaddress); $.fancybox({ 'width': 480, 'height': 360, 'autoscale': false, 'modal': false, 'autodimensions': false, 'centeronscroll': true, 'title': 'enews signup', 'titleposition': 'over', 'href': '#popupdiv', 'oncomplete': function () { $("#fancybox-inner").css({ 'top': '50px', 'bottom': 'auto', 'height': '320px' }); } }); return false; } }
open div in modal validation
<div style="display: none;"> <div id="popupdiv"> <div id="popupmessagediv" runat="server"> <asp:hiddenfield id="cinemaidhiddenfield" runat="server" /> <asp:literal id="failuretext" runat="server" enableviewstate="false"></asp:literal> <asp:validationsummary id="validationsummary1" cssclass="validationsummary" validationgroup="createuserwizard1" runat="server" headertext="<span>sorry, there problems information:</span>" /> <div id="confirmdetailsdiv" runat="server" visible="false" class="validationsummary positive"> <span>almost done! </span> <p> please review details below before submitting payment.<br /> </p> </div> <div class="form-row form-required"> <asp:label id="emaillabel" runat="server" associatedcontrolid="email">e-mail:</asp:label> <asp:textbox id="email" runat="server" cssclass="modalfieldtextbox" tooltip="please enter <strong>e-mail address</strong>." maxlength="98"></asp:textbox> <asp:customvalidator id="emailcustomvalidator" runat="server" errormessage="sorry, <strong>email address</strong> registered." controltovalidate="email" display="none" validationgroup="createuserwizard1"></asp:customvalidator> <asp:regularexpressionvalidator id="emailregularexpressionvalidator" runat="server" controltovalidate="email" display="none" errormessage="your <strong>email address</strong> not appear correct. " validationexpression="(\w[-._\w]*@\w[-._\w]*\w\.\w{2,3})" enableclientscript="true" validationgroup="createuserwizard1"></asp:regularexpressionvalidator> <asp:requiredfieldvalidator id="emailrequiredfieldvalidator" runat="server" controltovalidate="email" errormessage="you must enter <strong>email address</strong>." enableclientscript="true" validationgroup="createuserwizard1" display="none" setfocusonerror="false"></asp:requiredfieldvalidator> <asp:customvalidator id="customvalidator1" runat="server" display="none" enableclientscript="false" errormessage="customvalidator" validationgroup="createuserwizard1"></asp:customvalidator> </div> <br /> <div class="form-row form-required"> <asp:label id="emailconfirmlabel" runat="server" associatedcontrolid="emailconfirm"> confirm e-mail: </asp:label> <asp:textbox id="emailconfirm" runat="server" cssclass="modalfieldtextbox" tooltip="please enter <strong>e-mail address</strong>." maxlength="98"></asp:textbox> <asp:comparevalidator id="emailcomparevalidator" runat="server" enableclientscript="true" controltocompare="email" controltovalidate="emailconfirm" display="none" validationgroup="createuserwizard1" errormessage="your email address not match!"></asp:comparevalidator> </div> <br /> <div class="form-row form-required"> <asp:label id="postcodelabel" runat="server" associatedcontrolid="postcode"> post code:</asp:label> <asp:textbox id="postcode" runat="server" cssclass="modalfieldtextbox" maxlength="4"></asp:textbox> <ajaxtoolkit:filteredtextboxextender id="postcode_filteredtextboxextender" runat="server" enabled="true" filtertype="numbers" targetcontrolid="postcode"> </ajaxtoolkit:filteredtextboxextender> <asp:regularexpressionvalidator id="re6" controltovalidate="postcode" runat="server" validationgroup="createuserwizard1" validationexpression="^.{2,}$" errormessage="a postcode must have @ least 2 characters." tooltip="a postcode must have @ least 2 characters." display="none" enableclientscript="false"></asp:regularexpressionvalidator> <asp:regularexpressionvalidator id="postcoderegularexpressionvalidator" runat="server" controltovalidate="postcode" display="none" errormessage="sorry, post code must contain numbers." validationexpression="^[^<^>]*$" validationgroup="createuserwizard1" setfocusonerror="true" enableclientscript="false"></asp:regularexpressionvalidator> <asp:requiredfieldvalidator id="postcoderequiredfieldvalidator" runat="server" errormessage="please enter <strong>post code</strong>." controltovalidate="postcode" display="none" validationgroup="createuserwizard1"></asp:requiredfieldvalidator> <asp:customvalidator id="postcodecustomvalidator1" runat="server" controltovalidate="postcode" display="none" validationgroup="createuserwizard1" enableclientscript="false"></asp:customvalidator> </div> <br /> <div class="form-row form-required"> <span> </span> <asp:button id="createsubcriberbutton" runat="server" text="create subscriber" cssclass="buttonpositive" validationgroup="createuserwizard1" causesvalidation="true" onclick="createsubcriberbutton_click" onclientclick="return true;"/> </div> </div> </div>
but when click on createsubcriberbutton doesn't anything. should handled code behide
protected void createsubcriberbutton_click(object sender, eventargs e) { response.redirect("http://google.com.au"); }
i've inspect element , returns
<input type="submit" name="ctl00$belowheadercontentplaceholder$ctl00$createsubcriberbutton" value="create subscriber" onclick="return true;webform_dopostbackwithoptions(new webform_postbackoptions("ctl00$belowheadercontentplaceholder$ctl00$createsubcriberbutton", "", true, "createuserwizard1", "", false, false))" id="ctl00_belowheadercontentplaceholder_ctl00_createsubcriberbutton" class="buttonpositive">
i tried remove asp:validation controls , normal form submit no luck.
modal?
i've been using asp:button event handler method , worked till when tried adding form in modal.
appreciated.
Comments
Post a Comment