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. problems with variables

problems with variables

Scheduled Pinned Locked Moved ASP.NET
csharphelpquestionasp-net
2 Posts 2 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.
  • S Offline
    S Offline
    shankbond
    wrote on last edited by
    #1

    Hi, I have some problem with using variables, I am making a form in C#?asp.net . Now in my web application form I am having two controls on web page (dropdown, button); depending on the selection in the dropdown I have changed some value in a integer variable. PROBLEM: the variable retains this value until the event ends. after that I am using this value to do some processing; it is here that I find that the int value has changed back to 0(its default value). How can I prevent this as I need the value of the int? I have tried my code both by declaring the int variable as global to that form and also by declaring it inside that particular event. can someone please help me? thank You

    A 1 Reply Last reply
    0
    • S shankbond

      Hi, I have some problem with using variables, I am making a form in C#?asp.net . Now in my web application form I am having two controls on web page (dropdown, button); depending on the selection in the dropdown I have changed some value in a integer variable. PROBLEM: the variable retains this value until the event ends. after that I am using this value to do some processing; it is here that I find that the int value has changed back to 0(its default value). How can I prevent this as I need the value of the int? I have tried my code both by declaring the int variable as global to that form and also by declaring it inside that particular event. can someone please help me? thank You

      A Offline
      A Offline
      Arindam Sinha
      wrote on last edited by
      #2

      Do you have a check of PostBack in the Page_Load? If not then add that in for Form_Load. Declare the variable at class level. Then initialize the variable under if(!Page.IsPostBack).

      Regards, Arindam Sinha MyBlog - http://arindamsinha.wordpress.com/ Please give your feedback on this answer.

      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