There are two types of session events available in asp.net:

  • Session_Start
  • Session_End

You can auto generate number with character by this code-

VIEWSTATE The hidden form field that is used to transfer the state from the server to the client and back View State The mechanism that enables the asp.net controls to store state at the client. 
VIEWSTATE concepts

  • VIEWSTATEis an ASP.NET feature that provides for retaining the values of page and control properties that change from one execution of a page to another.
  • Before ASP.NET sends a page back to the client, it determines what changes the program has made to the properties of the page and its controls. These changes are encoded into a string that is assigned to the value of a hidden input field named C.
  • When the page is posted back to the server, the VIEWSTATE field is sent back to the server along with the HTTP request. Then, ASP.NET retrieves the property values from the VIEWSTATE field and uses them to restore the page and control properties.
  • ASP.NET also uses view state to save the values of the page properties it uses, such as IsPostBack.
  • VIEWSTATE  is not used to restore data entered by a user into a text box or any other input control unless the control responds to change events.
  • If VIEWSTATE  is enabled for a data-bound control, the control will not be rebound when the page is reposted. Instead, the controls values will be restored from view state.

ASP.NET uses session state to track the state of each user of an application. To do that, it creates a session stale object that contains a unique session ID for each users session. This ID is passed back to the browser as part of the response and then turned to the server with the next request. asp.net can then use the session ID to get the session state object thats associated with the request.

To create a cookie, you instantiate an object from the HttpCookie class. Then, you include it in the HTTP response that the server sends back to the browser, and the users browser stores the cookie either in its own memory or in a text file on the client machines disk. 
A cookie that stored in the browser memory is called a session cookie because it exists only for that session. When the browser session ends, the contents of any session cookies are lost. Session cookies are what asp.net uses to track session IDs. In contrast, persistent cookies are written to disk, so they are maintained after the browser session ends. Whether session or persistent, though, once a cookie is sent to a browser, it is automatically returned to the server with each HTTP request.
Besides using cookies for session IDs, you can use cookies to save information that identifies each user so the users do not have to enter that information each time they visit your web site. You can also use cookies to store information that lets you personalize the web pages that are displayed for a user.
When you use cookies to store this type of information, you should keep in mind that some users may have disabled cookies on their browsers. In that case, you would not be able to save cookies on the users computer. Unfortunately, asp.net does not provide a way for you to determine whether a user has disabled cookies. As a result, if you use cookies in an application, you may need to notify the user that cookies must be enabled to use it.

Need Help? Contact Us.

Log in

*
*

Forgot password?

*

New User

*
*
*
*