SubmitDisabledControls - A New Property in ASP.NET 2.0

Posted by: Scott on Writing, on 23 Jan 2006 | View original | NEW Bookmarked: 0 time(s)

Last week I blogged about the differences between read-only and disabled HTML elements, the main one being that read-only controls' values are posted back to the server on form submission, while disabled controls' values are not. With ASP.NET 2.0, the behavior changes slightly such that the ASP.NET TextBox, when its ReadOnly property is True, will not pick up any changes to the value it sent down to the client. This change in behavior can introduce a subtle bug for those relying on that behavior, as evidenced by this blog entry by Rick Strahl.

One of the issues with disabled controls is that if controls are marked disabled on the client-side, the values are not posted back and therefore any changes are lost from the previous visit. To demonstrate this, check out this demo. ASP.NET 2.0 adds a new property to the HtmlForm class (the server-side Web Form) that it designed to mitigate this problem. When set to True,the SubmitDisabledControls property injects a morsel of JavaScript in the <form> element's onsubmit event handler that sneakily goes in and marks all disabled form fields as enabled, in order to have their form values returned by the browser on postback. This property, as well as other workarounds to this problem (for those still in ASP.NET 1.x), are discussed in greater detail in my latest 4Guys article, Subtleties in Providing a Read-Only User Interface.

Advertisement
Category: ASP.NET | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 5434 | Hits: 164

Similar Posts

  • New article: How to detect and avoid memory and resources leaks in .NET applications more
  • Announcing Microsoft Ajax Library (Preview 6) and the Microsoft Ajax Minifier more
  • Sneak Peek: ASP.NET Splitter Control more
  • Gaia Ajax 3.6 Alpha released: Ajax GridView and Adaptive Rendering ++ more
  • Announcing the Microsoft AJAX CDN more
  • Sneak Peak: CSS Sprites Make Your Websites Faster more
  • Data-binding Telerik CoverFlow for Silverlight + some Routed Commands goodness more
  • New location (and look) for ASP.NET documentation more
  • Dovetail is Hiring a Junior-to-Mid-level .NET Developer more
  • Aspose.Total for .NET Q3 2009 Released more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD