<asp:TextBox ID="TextBox1" runat="server" onkeypress="return false;"/>
TextBox1.Attributes["readonly"] = "true";