Quantcast

ASP.NET 2.0: Submit Disabled Controls

Get the WebProNews Newsletter:
[ Business]

I recently built a JavaScript function in HeadLight that filled a textbox from JavaScript and then disabled the textbox to prevent the user to alter its contents.

When the form was submitted, it didn’t submit the contents of the disabled textbox.

It puzzled me, but then I found that ASP.NET 2.0 doesn’t submit client-side disabled controls by default. However, there is an easy way to force it to do so.

All you have to do is to put this line in the Page_Load:

Page.Form.SubmitDisabledControls = true;

The reason why I’ve never seen this property before, is that I have never had the need for it. I guess I’m just slow, but then again, slow is the new fast.

Tag:

Add to Del.icio.us | Digg | Reddit | Furl

Bookmark WebProNews:

Mads Kristensen currently works as a Senior Developer at Traceworks located
in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in
2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and
web services in his daily work as well. A true .NET developer with great passion for the simple solution.

http://www.madskristensen.dk/

ASP.NET 2.0: Submit Disabled Controls
About Mads Kristensen
Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution.

http://www.madskristensen.dk/ WebProNews Writer
Top Rated White Papers and Resources
  • Mithun

    Hello Sir,I still have a problem in submitting. Even after using this line “Page.Form.SubmitDisabledControls=true” still my disabled textbox values are not submitted.
    Can you suggest me anything, I need this ASAP because my project will be going live this friday. I will be waiting for your reply.

    Thanks
    Mithun

    • Guest

      yeah, it doesnt work. I think the solution is to use hidden fields to store anything that is visually presented as a disabled field, yet needs to be submitted. So the javascript has 2 form elements to update, on visual and one for the serverside code.

  • Guest

    it doesn’t work for me also………

    any other Ideas??

    Kind Regards,
    Saurabh