views:

444

answers:

1

We just recently migrated our web application from .NET 1.1 to .NET 2.0.

The web application was originally written in .NET 1.1 using Visual Studio 2003. To migrate it, we converted the solutions to VS2005.

Aside from some minor problems like RESX incompatibility and broken Calendar Controls, the Web Application worked.

However, we just tested it today and some postback functions are suddenly broken. In particular, the "File Browser" one. When the user clicks on the browse button, a new window will open (a custom page) that will allow him to browse for the file, the PATH will then be passed to the parent page then saved on a textbox, then it will postback to do some validation on the path. However, on POSTBACK, the path that was stored in a textbox is now gone and was replaced by the "default" path.

Is there something that we should watch out for in migrating from 1.1 to 2.0 that can break postbacks?

Thanks! :)

A: 

This is a design issue in ASP.NET 2.0.

My textbox was set to readonly. This behaviour is by design in ASP.NET 2.0 and it has been designed with the idea that a ReadOnly TextBox shouldnt be modified in the client side by a malicious code.

Workaround: Instead of setting the readonly property during design time, you should set in during runtime.

TextBox1.Attributes.Add("readonly", "readonly");

References: http://www.dotnetspider.com/resources/3120-ASP-NET--TextBox-Ready-Only-losing-client-side-changes-values-across-postback.aspx

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.readonly.aspx

Ian