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. General Programming
  3. C#
  4. ViewState property of asp.net Textbox

ViewState property of asp.net Textbox

Scheduled Pinned Locked Moved C#
csharpasp-netquestion
4 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.
  • K Offline
    K Offline
    karam chandrabose
    wrote on last edited by
    #1

    :laugh:Hi, am new to asp.net, i just wanted to eperiment the enableviewstate property. i have placed a textbox and a button on my page, in the page_load() i have the following code. void pageLoad() { if(! Page.IsPostback) TextBox1.Text = "Hi"; } void button1_click(object sender,eventargs evt) { } when i loaded the page the text box contained "Hi", and i had set the enableviewstate property of page as well as the textbox to false. now when i click on the button, still the textbox had "Hi" in it, i expect it to be cleared , can anyone explain me why it happens so? BABA thats what they say, B to the A to the B to the A. :laugh:

    Q 1 Reply Last reply
    0
    • K karam chandrabose

      :laugh:Hi, am new to asp.net, i just wanted to eperiment the enableviewstate property. i have placed a textbox and a button on my page, in the page_load() i have the following code. void pageLoad() { if(! Page.IsPostback) TextBox1.Text = "Hi"; } void button1_click(object sender,eventargs evt) { } when i loaded the page the text box contained "Hi", and i had set the enableviewstate property of page as well as the textbox to false. now when i click on the button, still the textbox had "Hi" in it, i expect it to be cleared , can anyone explain me why it happens so? BABA thats what they say, B to the A to the B to the A. :laugh:

      Q Offline
      Q Offline
      quiteSmart
      wrote on last edited by
      #2

      The button doesn't make any action in your form unless you tell it what to do. You can tell the button to make some action (clear the textbox) in the button1_click action. here you have it empty: void button1_click(object sender,eventargs evt) { } Just put in it some code, for example, you can put TextBox1.clear(); this will clear the text box. best regardes, Jamil Abou Khalil

      S K 2 Replies Last reply
      0
      • Q quiteSmart

        The button doesn't make any action in your form unless you tell it what to do. You can tell the button to make some action (clear the textbox) in the button1_click action. here you have it empty: void button1_click(object sender,eventargs evt) { } Just put in it some code, for example, you can put TextBox1.clear(); this will clear the text box. best regardes, Jamil Abou Khalil

        S Offline
        S Offline
        saud_a_k
        wrote on last edited by
        #3

        Actually I think it was a question about the working of the viewstate. I think if you redirect to anotherpage on button click, the come back to your page, the textbox value should'nt be there...

        _____________________________________________________ Yea! I could be wrong...

        1 Reply Last reply
        0
        • Q quiteSmart

          The button doesn't make any action in your form unless you tell it what to do. You can tell the button to make some action (clear the textbox) in the button1_click action. here you have it empty: void button1_click(object sender,eventargs evt) { } Just put in it some code, for example, you can put TextBox1.clear(); this will clear the text box. best regardes, Jamil Abou Khalil

          K Offline
          K Offline
          karam chandrabose
          wrote on last edited by
          #4

          Hi, I had written some code inside the button click event, i expect the text box to be cleared automatically after a post back..

          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