dcsimg
Results 1 to 2 of 2

Thread: view state session management problem!!!!

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2009
    Posts
    1,103

    Unhappy view state session management problem!!!!

    view state is used to retain the data,its scope is only within the page in which it is declared.....
    So I did a very simple program but here the values of i is not retained after the button click.....
    Code:
     Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim i As Integer = ViewState("Increment")
            i += 1
            Label1.Text = i
            ViewState("Incremant") = i
        End Sub
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not IsPostBack Then
                ViewState("Increment") = 0
            End If
        End Sub
    How to retain the values between the button click then?

    Please help!!!

  2. #2
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: view state session management problem!!!!

    You have a typing error

    Dim i As Integer = ViewState("Increment") -->Increment
    i += 1
    Label1.Text = i
    ViewState("Incremant") = i --->Incremant change to Increment

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width