Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. regarding variables declared in a page

regarding variables declared in a page

Scheduled Pinned Locked Moved ASP.NET
design
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vijaylumar
    wrote on last edited by
    #1

    hi i worked on windows application and now i m working on web application for the first time. the following is my code in defalut page Partial Class _Default Inherits System.Web.UI.Page Dim i As Integer = 0 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click i = i + 1 MsgBox(i.ToString()) End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click i = i * 100 MsgBox(i.ToString()) End Sub End Class when i click button1 the value in i is 1. but when i click button2,it is showing the value in i is 0 but ihave to get 100 can any one tell me whats happening at button2

    M N 2 Replies Last reply
    0
    • V vijaylumar

      hi i worked on windows application and now i m working on web application for the first time. the following is my code in defalut page Partial Class _Default Inherits System.Web.UI.Page Dim i As Integer = 0 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click i = i + 1 MsgBox(i.ToString()) End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click i = i * 100 MsgBox(i.ToString()) End Sub End Class when i click button1 the value in i is 1. but when i click button2,it is showing the value in i is 0 but ihave to get 100 can any one tell me whats happening at button2

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      First, format your code using the pre tags when posting. You've been around long enough to know this. Understand that the web, and ASP.NET, is stateless. Each time a page is requested, or an action, such as a button click, causes a postback, all the variables you have declared are set to their default values unless otherwise persisted. You will do well to pick up a book on ASP.NET and read it before proceeding.


      I know the language. I've read a book. - _Madmatt

      1 Reply Last reply
      0
      • V vijaylumar

        hi i worked on windows application and now i m working on web application for the first time. the following is my code in defalut page Partial Class _Default Inherits System.Web.UI.Page Dim i As Integer = 0 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click i = i + 1 MsgBox(i.ToString()) End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click i = i * 100 MsgBox(i.ToString()) End Sub End Class when i click button1 the value in i is 1. but when i click button2,it is showing the value in i is 0 but ihave to get 100 can any one tell me whats happening at button2

        M Offline
        M Offline
        m dhu
        wrote on last edited by
        #3

        vijaylumar wrote:

        Dim i As Integer = 0

        you declared i as 0 so you get result as 0

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups