How to Get ReadOnly in TextBox Using Asp.net C#

TEXTBOX READONLY


The ReadOnly property is used to set or return whether or not the text in the TextBox control can be changed.

Read-only or disabled attribute to form fields (textbox, label, checkbox, text area).




Read Only Attribute

Read Only form fields or elements values post to the server for processing.
Read Only form fields or elements get focus.
Read Only form fields or elements are included while tab navigation.
Some browsers do not provide default style for Read-Only form fields or elements.



First  - Select Textbox from ToolBox -  Go to Property window  -  Select  Readonly=True






HTML CODING


<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table><tr><td>
        <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label></td>
        <td><asp:TextBox ID="TextBox1" runat="server" ReadOnly="True">DOTNET</asp:TextBox></td>
        </tr>
        </table>
    </div>
    </form>
</body>
</html>



Next - Go to property Window  Text = Enter some text 










Next - F5 Run the program   -  Only Read TextBox Values  




                                         

0 comments:

Post a Comment