5

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?

Davide Piras
  • 43,984
  • 10
  • 98
  • 147
Raihan Alam
  • 91
  • 1
  • 8
  • 3
    Is there a question in there? I can't see one. – Lazarus Sep 21 '11 at 12:41
  • I did some modifications, can you see the question now? – Raihan Alam Sep 21 '11 at 15:30
  • I have a similar problem, but I'm using OnClientClick. The clientSubmit option is being hardcoded to false in the generated code: WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("enroll1$btnSubmitCC", "", true, "", "", false, false)); – xr280xr Sep 22 '11 at 22:00
  • Mine is getting a script error when I clicked submit, but only in FireFox due to an event validation exception. Still trying to figure out why, but just thought I'd share since script errors are pretty much hidden in FireFox now. – xr280xr Sep 26 '11 at 17:59
  • Are you using an UpdatePanel? – rick schott Oct 05 '11 at 02:00
  • @rickschott yes,I am using update panel – Raihan Alam Nov 02 '11 at 10:19

4 Answers4

3

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..

techBeginner
  • 3,792
  • 11
  • 43
  • 59
2

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

rick schott
  • 21,012
  • 5
  • 52
  • 81
1

You're not using anything to prevent repeated submission of the form?

I had exactly the same issue, the .Net validation method indicated that the form was valid, but options.clientSubmit was always false :S

The culprit turned out to be:

<script type="text/javascript">
    $(document).ready(function() {
        $('.prevDblSubmit').preventDoubleSubmit();
    })
</script>
0

This seems that should be working, instead of using meta:resourcekey="btnSubmitResource1", try explicit localization. See question: ASP.NET: explicit vs implicit localization?

Community
  • 1
  • 1
HoBa
  • 3,442
  • 5
  • 26
  • 33