Wednesday, November 05, 2008

How to make asp.net textbox readonly

A asp.net2 textbox control will not perform any postback if the readonly is set to true. Thus, no validation could be performed if required.

Why not setting the atttribute client side? This disables the user from editing the value. Moreover, it supports post back. Cool. :)

// Make the textbox readonly at client side
txbDailyAllowance.Attributes.Add("readonly", "readonly");

No comments: