- The TextBox control.
- The CheckBox control.
- The RadioButton control.
1) Create a Web Site project
2) Add a web page to project for example Default.aspx
3) Add below HTML code to Default.aspx page
<form id="form1" runat="server">
<div>
<label enableviewstate="false" id="lblTest" runat="server"></label>
<textbox enableviewstate="false" id="txtTest" runat="server"></textbox>
<button id="Button1" runat="server" text="Submit" type="submit"></button></div>
</form>
4) Write below code in Page_Load event in Default.aspx.cs
(!IsPostBack)
if
{
lblTest.Text = "Test Label";
txtTest.BackColor = Color.FromName("Tomato");
txtTest.Text = "Test TextBox";
}
5) Save and compile your project, and then browse to the .aspx page.
6) Now click on Submit button and observe the changes.
When you resubmit the page , Label Text is lost . Also , Textbox Backcolor is lost where as Textbox Text is retained
No comments:
Post a Comment