Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET button options.clientSubmit is set to false

I have a ASP.NET button which sometimes does not post back. I checked this in IE developer and found that when the button does not work options.clientSubmit is set to false in the function WebForm_DoPostBackWithOptions()

My button code

<asp:Button 
           runat="server" 
           ID="btnSubmit" 
           CssClass="button" 
           OnClick="btnSubmit_Click"  
           meta:resourcekey="btnSubmitResource1" />

Inside WebForm_DoPostBackWithOptions(options)

    if (options.clientSubmit) {
    __doPostBack(options.eventTarget, options.eventArgument);
    }

Can anyone tell me why the button sometimes works and sometimes does not? what should I do to make it work always?

like image 807
Raihan Alam Avatar asked Sep 21 '11 12:09

Raihan Alam


2 Answers

This may be a possibility:

Check if you have any Validators on the page which have not been grouped to any ValidationGroup and may be visible false(may be due container is visible false). This validator may be validating the control which is of no relevance under this circumstance and causing the postback to cancel saying it invalid.

If you find any, to group all the related controls, assign a ValidationGroup to all the corresponding Validators and then assign that group to your submit control(whichever causes postback). This is most common mistake I have seen..

like image 70
dotNETbeginner Avatar answered Sep 20 '22 05:09

dotNETbeginner


Try adding CausesValidation = "False" and see what happens. I suspect you have some validation that isn't passing.

like image 21
rick schott Avatar answered Sep 20 '22 05:09

rick schott