469,607 Members | 2,203 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,607 developers. It's quick & easy.

When programming with Visual Studio in code. What means the Label in code?


for what is the label good when programming in visual studio like this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Label1: If Page.IsPostBack Then
End If

Label2: DoThat()

End Sub

For what do I need or can use "Label1" and "Label2" ?

Thanks for any help an answers in advance!
Nov 18 '05 #1
2 1140

ASP.NET comes with build in mechanism of server events. Those events
start with a user action that took place on the client side. The user
action causes the page to be submitted back to the server. On the server
side the page events called, including certain control event. to
minimize the impact of recreating controls on post back MS create
another mechanism that saves controls state on the server into hidden
field that send to the client and send back to the server when server
side event required. ASP.NET use hidden field data to recreate controls
on the server (instead of recreating them for DB, for example).
IsPostBack is indication if the current call to the server side call is
result of Server side event or first time page call. You should use it
to prevent recreating of controls on postback.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #2

Example, you have a dropdownlist populated with names from a database
when page loads, and the user then selects an item.

When the user clicks on another control that causes postback (list,
button, etc.), you do not want your dropdownlist to repopulate from the
database, you want to keep the item the user selected.

So you set the dropdownlist control in the page load sub, using page is
(or is not) postback.
If Not IsPostBack Then

'populate dropdownlist here

End if

Please note that you don't need the "Else" part of the statement if you
are using ViewState...it will remember what the user selected from the


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Jack Charbonneau | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.