ViewState property of asp.net Textbox
-
: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:
-
: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:
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 putTextBox1.clear();
this will clear the text box. best regardes, Jamil Abou Khalil -
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 putTextBox1.clear();
this will clear the text box. best regardes, Jamil Abou KhalilActually 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...
-
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 putTextBox1.clear();
this will clear the text box. best regardes, Jamil Abou KhalilHi, I had written some code inside the button click event, i expect the text box to be cleared automatically after a post back..