SubmitDisabledControls - A New Property in ASP.NET 2.0

Posted by: Scott on Writing, on 23 Jan 2006 | View original | 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: 7363 | Hits: 167

Similar Posts

  • Using SqlBulkCopy To Perform Efficient Bulk SQL Operations more
  • TIP: How To Generate a Fully Qualified URL in ASP.NET (E.g., http://www.yourserver.com/folder/file.aspx) more
  • Data-binding Telerik CoverFlow for Silverlight + some Routed Commands goodness more
  • MPI Project Template for VS2010 more
  • How to: Validate data with SL/WPF RadGridView Part I validating on property/cell level via Data Annotations more
  • Introducing Recurring Appointments for Web.UI Scheduler ASP.NET AJAX more
  • New Entity Framework Feature CTP for VS2010 Beta 2 more
  • EF4: Lazy Loading on By Default but what about pre Beta 2 Models? more
  • Dynamic in C# 4.0: Creating Wrappers with DynamicObject more
  • Animation Hack Using Attached Properties in Silverlight 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