ASP NET 4 BASICS USING VISUAL STUDIO 2012 Part 3 (View State)
PRE-REQUISITE
Previous tutorial : http://visualstudio-steps.blogspot.com/2014/01/asp-net-4-basics-using-visual-studio_4.html
Or
Download startup file:
STEPS
1) Open the Web Site vbsite101.
Open Default.aspx.
2) In the Design Mode, create a new <p> element below the object myTimeLabel (click an area beside the object [myTimeLabel] and press ENTER key)
3) Add control objects; TextBox, Button and Label.
Click the object icon in the Toolbox, drag and drop them into the <p> element.
Design outcome:
Code outcome:
4) Add OnClick property to the Button.
OnClick=”Click”
|
Code outcome:
4) Add action codes that will respond to Click event.
Sub Click(ByVal s As Object, ByVal e As EventArgs)
Label1.Text = TextBox1.Text
End Sub
|
Code outcome:
5) Run.
1. Type “Hello” into the Text Box.
2. Click the Button
3. The text “Hello” appears in the Label.
C# EXERCISE
Use the action codes below for the Click event (for C# language):
void Click(Object s, EventArgs e)
{
Label1.Text = TextBox1.Text;
}
|
DISCUSSION
ASP.NET controls automatically retain their data when a page is sent to the server in response to an event (such as a user clicking a button). Microsoft calls this persistence
of data view state.
ASP.NET pages maintain view state by encrypting the data within a hidden form field.
This takes up additional resources. If you don’t intend to use view state, it is recommended that you disable it.
DOWNLOAD
---
No comments:
Post a Comment