Connecting Tech Pros Worldwide Help | Site Map

New to ASP.NET - A very basic question regarding the ViewState and Server Round Trips

msnews.microsoft.com
Guest
 
Posts: n/a
#1: Nov 19 '05
Hello All,

I am very new to ASP.NET and I have a basic question. Can somebody please
explain?

I have an .aspx Web Page with a textbox control.

When the Page initially loads I am calling a Javascript function to write a
text information in the text box.

After that when I refresh the Page, I was hoping the information in the
textbox will be lost. But it stays.

I thought the 'EnableViewState' is set to 'True' and I made it 'False'.

Then when I refresh the page still my text stays in the TextBox.

This is confusing me.

I thought WebPages make round trips to server and hence new page is loaded
everytime. But how is my text still staying the text box?

Any suggestion?

Thanks for your time.

Regards
Anand Ganesh


Karl Seguin
Guest
 
Posts: n/a
#2: Nov 19 '05

re: New to ASP.NET - A very basic question regarding the ViewState and Server Round Trips


This isnt' an ASP.Net thing...it's how most browsers behave...go to
www.google.com, enter some text and hit f5/reload...the text will stay...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"msnews.microsoft.com" <aganesh@nobel-systems.com> wrote in message
news:OcURDfqRFHA.3288@TK2MSFTNGP14.phx.gbl...[color=blue]
> Hello All,
>
> I am very new to ASP.NET and I have a basic question. Can somebody please
> explain?
>
> I have an .aspx Web Page with a textbox control.
>
> When the Page initially loads I am calling a Javascript function to write
> a text information in the text box.
>
> After that when I refresh the Page, I was hoping the information in the
> textbox will be lost. But it stays.
>
> I thought the 'EnableViewState' is set to 'True' and I made it 'False'.
>
> Then when I refresh the page still my text stays in the TextBox.
>
> This is confusing me.
>
> I thought WebPages make round trips to server and hence new page is loaded
> everytime. But how is my text still staying the text box?
>
> Any suggestion?
>
> Thanks for your time.
>
> Regards
> Anand Ganesh
>[/color]


msnews.microsoft.com
Guest
 
Posts: n/a
#3: Nov 19 '05

re: New to ASP.NET - A very basic question regarding the ViewState and Server Round Trips


Hi Karl,

I tried doing this in google.com and everytime I refresh I am getting a
fresh page back with no text.

This is what I am expecting in my ASP.NET app but is not happening.

Thanks
Anand


"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:e7WasyqRFHA.1096@tk2msftngp13.phx.gbl...[color=blue]
> This isnt' an ASP.Net thing...it's how most browsers behave...go to
> www.google.com, enter some text and hit f5/reload...the text will stay...
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is
> annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
> "msnews.microsoft.com" <aganesh@nobel-systems.com> wrote in message
> news:OcURDfqRFHA.3288@TK2MSFTNGP14.phx.gbl...[color=green]
>> Hello All,
>>
>> I am very new to ASP.NET and I have a basic question. Can somebody please
>> explain?
>>
>> I have an .aspx Web Page with a textbox control.
>>
>> When the Page initially loads I am calling a Javascript function to write
>> a text information in the text box.
>>
>> After that when I refresh the Page, I was hoping the information in the
>> textbox will be lost. But it stays.
>>
>> I thought the 'EnableViewState' is set to 'True' and I made it 'False'.
>>
>> Then when I refresh the page still my text stays in the TextBox.
>>
>> This is confusing me.
>>
>> I thought WebPages make round trips to server and hence new page is
>> loaded everytime. But how is my text still staying the text box?
>>
>> Any suggestion?
>>
>> Thanks for your time.
>>
>> Regards
>> Anand Ganesh
>>[/color]
>
>[/color]


Steve C. Orr [MVP, MCSD]
Guest
 
Posts: n/a
#4: Nov 19 '05

re: New to ASP.NET - A very basic question regarding the ViewState and Server Round Trips


Textboxes don't use viewstate to store their text property.
This is handled by standard HTML.
If you want to clear the textbox then use code like this:
MyTextBox.Text = ""

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


"msnews.microsoft.com" <aganesh@nobel-systems.com> wrote in message
news:OcURDfqRFHA.3288@TK2MSFTNGP14.phx.gbl...[color=blue]
> Hello All,
>
> I am very new to ASP.NET and I have a basic question. Can somebody please
> explain?
>
> I have an .aspx Web Page with a textbox control.
>
> When the Page initially loads I am calling a Javascript function to write
> a text information in the text box.
>
> After that when I refresh the Page, I was hoping the information in the
> textbox will be lost. But it stays.
>
> I thought the 'EnableViewState' is set to 'True' and I made it 'False'.
>
> Then when I refresh the page still my text stays in the TextBox.
>
> This is confusing me.
>
> I thought WebPages make round trips to server and hence new page is loaded
> everytime. But how is my text still staying the text box?
>
> Any suggestion?
>
> Thanks for your time.
>
> Regards
> Anand Ganesh
>[/color]


msnews.microsoft.com
Guest
 
Posts: n/a
#5: Nov 19 '05

re: New to ASP.NET - A very basic question regarding the ViewState and Server Round Trips


Steve,

Thanks for the info.

Here is what I observed in my ASP.NET application.

Observation 1:
Every time I do refresh (ctrl-F5) even if I add a text in my text box it is
cleared and whenever I do refresh I am geting fresh page with no text. So
this is exactly what I am expecting.


Observation 2:
When I click once on the ASP:Button which is on my page, then the page is
not loading but only the Postback event is happening. So during this
Postback event whatever Text info I used for the First Submit always stays
in my text box. Even if I change the value latter and then do a refresh
whatever Text Info I used for the First Submit stays in the text box.

So my question is

What is happening during the "ASP:Button" click event?

I thought it makes a round trip to server and behave same as the initial
page load event but it is not like that.

Can you please clarify?

Thanks
Anand Ganesh




"Steve C. Orr [MVP, MCSD]" <Steve@Orr.net> wrote in message
news:eB5yBCrRFHA.2664@TK2MSFTNGP15.phx.gbl...[color=blue]
> Textboxes don't use viewstate to store their text property.
> This is handled by standard HTML.
> If you want to clear the textbox then use code like this:
> MyTextBox.Text = ""
>
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net
>
>
> "msnews.microsoft.com" <aganesh@nobel-systems.com> wrote in message
> news:OcURDfqRFHA.3288@TK2MSFTNGP14.phx.gbl...[color=green]
>> Hello All,
>>
>> I am very new to ASP.NET and I have a basic question. Can somebody please
>> explain?
>>
>> I have an .aspx Web Page with a textbox control.
>>
>> When the Page initially loads I am calling a Javascript function to write
>> a text information in the text box.
>>
>> After that when I refresh the Page, I was hoping the information in the
>> textbox will be lost. But it stays.
>>
>> I thought the 'EnableViewState' is set to 'True' and I made it 'False'.
>>
>> Then when I refresh the page still my text stays in the TextBox.
>>
>> This is confusing me.
>>
>> I thought WebPages make round trips to server and hence new page is
>> loaded everytime. But how is my text still staying the text box?
>>
>> Any suggestion?
>>
>> Thanks for your time.
>>
>> Regards
>> Anand Ganesh
>>[/color]
>
>[/color]


Steve C. Orr [MVP, MCSD]
Guest
 
Posts: n/a
#6: Nov 19 '05

re: New to ASP.NET - A very basic question regarding the ViewState and Server Round Trips


The value of the textbox is being posted back to the page upon each
postback.
This is standard HTML functionality and is not related to ASP.NET.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


"msnews.microsoft.com" <aganesh@nobel-systems.com> wrote in message
news:OkgGZKsRFHA.1392@TK2MSFTNGP10.phx.gbl...[color=blue]
> Steve,
>
> Thanks for the info.
>
> Here is what I observed in my ASP.NET application.
>
> Observation 1:
> Every time I do refresh (ctrl-F5) even if I add a text in my text box it
> is cleared and whenever I do refresh I am geting fresh page with no text.
> So this is exactly what I am expecting.
>
>
> Observation 2:
> When I click once on the ASP:Button which is on my page, then the page is
> not loading but only the Postback event is happening. So during this
> Postback event whatever Text info I used for the First Submit always stays
> in my text box. Even if I change the value latter and then do a refresh
> whatever Text Info I used for the First Submit stays in the text box.
>
> So my question is
>
> What is happening during the "ASP:Button" click event?
>
> I thought it makes a round trip to server and behave same as the initial
> page load event but it is not like that.
>
> Can you please clarify?
>
> Thanks
> Anand Ganesh
>
>
>
>
> "Steve C. Orr [MVP, MCSD]" <Steve@Orr.net> wrote in message
> news:eB5yBCrRFHA.2664@TK2MSFTNGP15.phx.gbl...[color=green]
>> Textboxes don't use viewstate to store their text property.
>> This is handled by standard HTML.
>> If you want to clear the textbox then use code like this:
>> MyTextBox.Text = ""
>>
>> --
>> I hope this helps,
>> Steve C. Orr, MCSD, MVP
>> http://SteveOrr.net
>>
>>
>> "msnews.microsoft.com" <aganesh@nobel-systems.com> wrote in message
>> news:OcURDfqRFHA.3288@TK2MSFTNGP14.phx.gbl...[color=darkred]
>>> Hello All,
>>>
>>> I am very new to ASP.NET and I have a basic question. Can somebody
>>> please explain?
>>>
>>> I have an .aspx Web Page with a textbox control.
>>>
>>> When the Page initially loads I am calling a Javascript function to
>>> write a text information in the text box.
>>>
>>> After that when I refresh the Page, I was hoping the information in the
>>> textbox will be lost. But it stays.
>>>
>>> I thought the 'EnableViewState' is set to 'True' and I made it 'False'.
>>>
>>> Then when I refresh the page still my text stays in the TextBox.
>>>
>>> This is confusing me.
>>>
>>> I thought WebPages make round trips to server and hence new page is
>>> loaded everytime. But how is my text still staying the text box?
>>>
>>> Any suggestion?
>>>
>>> Thanks for your time.
>>>
>>> Regards
>>> Anand Ganesh
>>>[/color]
>>
>>[/color]
>
>[/color]


Steve C. Orr [MVP, MCSD]
Guest
 
Posts: n/a
#7: Nov 19 '05

re: New to ASP.NET - A very basic question regarding the ViewState and Server Round Trips


The value of the textbox is being posted back to the page upon each
postback.
This is standard HTML functionality and is not related to ASP.NET.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


"msnews.microsoft.com" <aganesh@nobel-systems.com> wrote in message
news:OkgGZKsRFHA.1392@TK2MSFTNGP10.phx.gbl...[color=blue]
> Steve,
>
> Thanks for the info.
>
> Here is what I observed in my ASP.NET application.
>
> Observation 1:
> Every time I do refresh (ctrl-F5) even if I add a text in my text box it
> is cleared and whenever I do refresh I am geting fresh page with no text.
> So this is exactly what I am expecting.
>
>
> Observation 2:
> When I click once on the ASP:Button which is on my page, then the page is
> not loading but only the Postback event is happening. So during this
> Postback event whatever Text info I used for the First Submit always stays
> in my text box. Even if I change the value latter and then do a refresh
> whatever Text Info I used for the First Submit stays in the text box.
>
> So my question is
>
> What is happening during the "ASP:Button" click event?
>
> I thought it makes a round trip to server and behave same as the initial
> page load event but it is not like that.
>
> Can you please clarify?
>
> Thanks
> Anand Ganesh
>
>
>
>
> "Steve C. Orr [MVP, MCSD]" <Steve@Orr.net> wrote in message
> news:eB5yBCrRFHA.2664@TK2MSFTNGP15.phx.gbl...[color=green]
>> Textboxes don't use viewstate to store their text property.
>> This is handled by standard HTML.
>> If you want to clear the textbox then use code like this:
>> MyTextBox.Text = ""
>>
>> --
>> I hope this helps,
>> Steve C. Orr, MCSD, MVP
>> http://SteveOrr.net
>>
>>
>> "msnews.microsoft.com" <aganesh@nobel-systems.com> wrote in message
>> news:OcURDfqRFHA.3288@TK2MSFTNGP14.phx.gbl...[color=darkred]
>>> Hello All,
>>>
>>> I am very new to ASP.NET and I have a basic question. Can somebody
>>> please explain?
>>>
>>> I have an .aspx Web Page with a textbox control.
>>>
>>> When the Page initially loads I am calling a Javascript function to
>>> write a text information in the text box.
>>>
>>> After that when I refresh the Page, I was hoping the information in the
>>> textbox will be lost. But it stays.
>>>
>>> I thought the 'EnableViewState' is set to 'True' and I made it 'False'.
>>>
>>> Then when I refresh the page still my text stays in the TextBox.
>>>
>>> This is confusing me.
>>>
>>> I thought WebPages make round trips to server and hence new page is
>>> loaded everytime. But how is my text still staying the text box?
>>>
>>> Any suggestion?
>>>
>>> Thanks for your time.
>>>
>>> Regards
>>> Anand Ganesh
>>>[/color]
>>
>>[/color]
>
>[/color]


Closed Thread