Hi, All
I create an ASP.NET page, it contains FirstName textbox and LastName
textbox. I setup "enableViewState=false" in page directive. When I enter
data in FirstName and LastName textbox, after I refresh the page or go to
different page and come back to the same page, I find data entered in
FirstName and LastName textbox are still there.
I think after setup "enableViewState=false" , we are not suppose to see data
in the textbox after we move to another page and come back?
Please help.
Thanks
Kai 9 2675
Hi,
disabling ViewState has no effect on TextBox..
Take a look at my blog post for an explanation http://blogs.aspadvice.com/joteke/ar...03/15/767.aspx
This relates to the posting behaviour (when page posts back to itself), but
you said "come back to the same page". Are you visiting another completely
separate ASP.NET page and then return to the original Page containing
TextBoxes and they still keep the state!?
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist http://blogs.aspadvice.com/joteke
"kai" <ka******@earthlink.net> wrote in message
news:IL*****************@newsread3.news.atl.earthl ink.net... Hi, All
I create an ASP.NET page, it contains FirstName textbox and LastName textbox. I setup "enableViewState=false" in page directive. When I enter data in FirstName and LastName textbox, after I refresh the page or go to different page and come back to the same page, I find data entered in FirstName and LastName textbox are still there.
I think after setup "enableViewState=false" , we are not suppose to see
data in the textbox after we move to another page and come back?
Please help.
Thanks
Kai
Hi Kai,
From your description, you found that the ASP.NET textbox control's entered
value will remain after posted back no matter the page's viewstate is
enabled or not ,yes?
As for this problem, here are my understanding:
In fact ,the page's viewstate is really disabled. And any setting on the
serverside won't be able to remain between post backs. For example, you try
the following code(when page's viewstate is disabled):
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
TextBox1.TextMode = TextBoxMode.Password;
}
}
Then, when the page is first time loaded, the TextBox1 is a password mode.
If you post back the page(add a submit button), you'll find the TextBox1's
mode turn back to normal(singleline).
Then, you must be confused why the value in the textbox remains after post
back, yes? This is because the entered value is rendered out with the
TextBox after post back. For example, when the page is posted back, at the
serverside, the textbox will pass through the following steps:
1. its control instance be contructed
2. Restore its states from the viewstate
3. Compare the states with its new inputed value( this is the new value we
get which is actually in the Request.Form collection)
4. Change the textbox's state(value) to the new value
5.... process the textbox's postback event( if exist)
6. The textbox is rendered with the new value (when the page is
renderedout).
The #6 is the key point why the new value will remain , because the textbox
is rendered out as html element which has contain the new value such as
<input type="text" value="new value" />, no viewstate needed. Do you think
so?
If you have anything unclear, please feel free to post here. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Hi, Teemu
Thanks for helping me. I read your page explanation.
Yes, I visit completely another ASP.NET page, when I navigate back, data
still ramain in the textboxs and radio button.
Only password field data cleared.
Thanks
Kai
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:uj**************@TK2MSFTNGP11.phx.gbl... Hi,
disabling ViewState has no effect on TextBox..
Take a look at my blog post for an explanation http://blogs.aspadvice.com/joteke/ar...03/15/767.aspx
This relates to the posting behaviour (when page posts back to itself),
but you said "come back to the same page". Are you visiting another completely separate ASP.NET page and then return to the original Page containing TextBoxes and they still keep the state!?
-- Teemu Keiski MCP, Microsoft MVP (ASP.NET), AspInsiders member ASP.NET Forum Moderator, AspAlliance Columnist http://blogs.aspadvice.com/joteke
"kai" <ka******@earthlink.net> wrote in message news:IL*****************@newsread3.news.atl.earthl ink.net... Hi, All
I create an ASP.NET page, it contains FirstName textbox and LastName textbox. I setup "enableViewState=false" in page directive. When I enter data in FirstName and LastName textbox, after I refresh the page or go
to different page and come back to the same page, I find data entered in FirstName and LastName textbox are still there.
I think after setup "enableViewState=false" , we are not suppose to see data in the textbox after we move to another page and come back?
Please help.
Thanks
Kai
Hi, Steven
Thanks for helping me. I am learning and try to understand your
explanation. If I have questions, I will postback to you for help.
Thanks again
Kai
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:ju**************@cpmsftngxa10.phx.gbl... Hi Kai,
From your description, you found that the ASP.NET textbox control's
entered value will remain after posted back no matter the page's viewstate is enabled or not ,yes?
As for this problem, here are my understanding: In fact ,the page's viewstate is really disabled. And any setting on the serverside won't be able to remain between post backs. For example, you
try the following code(when page's viewstate is disabled): private void Page_Load(object sender, System.EventArgs e) { if(!IsPostBack) { TextBox1.TextMode = TextBoxMode.Password; } }
Then, when the page is first time loaded, the TextBox1 is a password mode. If you post back the page(add a submit button), you'll find the TextBox1's mode turn back to normal(singleline).
Then, you must be confused why the value in the textbox remains after post back, yes? This is because the entered value is rendered out with the TextBox after post back. For example, when the page is posted back, at the serverside, the textbox will pass through the following steps: 1. its control instance be contructed
2. Restore its states from the viewstate
3. Compare the states with its new inputed value( this is the new value we get which is actually in the Request.Form collection)
4. Change the textbox's state(value) to the new value
5.... process the textbox's postback event( if exist)
6. The textbox is rendered with the new value (when the page is renderedout).
The #6 is the key point why the new value will remain , because the
textbox is rendered out as html element which has contain the new value such as <input type="text" value="new value" />, no viewstate needed. Do you think so?
If you have anything unclear, please feel free to post here. Thanks.
Regards,
Steven Cheng Microsoft Online Support
Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Get Preview at ASP.NET whidbey http://msdn.microsoft.com/asp.net/whidbey/default.aspx
OK,
by navigating back do you use Back button of browser or do you use explicit
link (at the another page) to get back to the page with TextBoxes?
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist http://blogs.aspadvice.com/joteke
"kai" <ka******@earthlink.net> wrote in message
news:Ys*****************@newsread3.news.atl.earthl ink.net...
Hi, Teemu
Thanks for helping me. I read your page explanation.
Yes, I visit completely another ASP.NET page, when I navigate back, data
still ramain in the textboxs and radio button.
Only password field data cleared.
Thanks
Kai
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:uj**************@TK2MSFTNGP11.phx.gbl... Hi,
disabling ViewState has no effect on TextBox..
Take a look at my blog post for an explanation http://blogs.aspadvice.com/joteke/ar...03/15/767.aspx
This relates to the posting behaviour (when page posts back to itself),
but you said "come back to the same page". Are you visiting another completely separate ASP.NET page and then return to the original Page containing TextBoxes and they still keep the state!?
-- Teemu Keiski MCP, Microsoft MVP (ASP.NET), AspInsiders member ASP.NET Forum Moderator, AspAlliance Columnist http://blogs.aspadvice.com/joteke
"kai" <ka******@earthlink.net> wrote in message news:IL*****************@newsread3.news.atl.earthl ink.net... Hi, All
I create an ASP.NET page, it contains FirstName textbox and LastName textbox. I setup "enableViewState=false" in page directive. When I enter data in FirstName and LastName textbox, after I refresh the page or go
to different page and come back to the same page, I find data entered in FirstName and LastName textbox are still there.
I think after setup "enableViewState=false" , we are not suppose to see data in the textbox after we move to another page and come back?
Please help.
Thanks
Kai
I use browser link to go back to the page which has the textbox.
After I read your help, I change to explicit link, then the textbox and
radio button lose all the data. It seems to me ViewState = False take effect
when use explicit link to navigate. Why?
Thanks
Kai
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:e4*************@TK2MSFTNGP09.phx.gbl... OK,
by navigating back do you use Back button of browser or do you use
explicit link (at the another page) to get back to the page with TextBoxes?
-- Teemu Keiski MCP, Microsoft MVP (ASP.NET), AspInsiders member ASP.NET Forum Moderator, AspAlliance Columnist http://blogs.aspadvice.com/joteke
"kai" <ka******@earthlink.net> wrote in message news:Ys*****************@newsread3.news.atl.earthl ink.net... Hi, Teemu Thanks for helping me. I read your page explanation. Yes, I visit completely another ASP.NET page, when I navigate back, data still ramain in the textboxs and radio button. Only password field data cleared.
Thanks Kai "Teemu Keiski" <jo****@aspalliance.com> wrote in message news:uj**************@TK2MSFTNGP11.phx.gbl... Hi,
disabling ViewState has no effect on TextBox..
Take a look at my blog post for an explanation http://blogs.aspadvice.com/joteke/ar...03/15/767.aspx
This relates to the posting behaviour (when page posts back to itself), but you said "come back to the same page". Are you visiting another
completely separate ASP.NET page and then return to the original Page containing TextBoxes and they still keep the state!?
-- Teemu Keiski MCP, Microsoft MVP (ASP.NET), AspInsiders member ASP.NET Forum Moderator, AspAlliance Columnist http://blogs.aspadvice.com/joteke
"kai" <ka******@earthlink.net> wrote in message news:IL*****************@newsread3.news.atl.earthl ink.net... Hi, All
I create an ASP.NET page, it contains FirstName textbox and LastName textbox. I setup "enableViewState=false" in page directive. When I
enter data in FirstName and LastName textbox, after I refresh the page or go to different page and come back to the same page, I find data entered in FirstName and LastName textbox are still there.
I think after setup "enableViewState=false" , we are not suppose to
see data in the textbox after we move to another page and come back?
Please help.
Thanks
Kai
When I use explicit link, I lose all the data it does not matter ViewState =
True or False. So is it true ViewState=true cannot maintain data if we use
explicit link?
Thanks
Kai
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:e4*************@TK2MSFTNGP09.phx.gbl... OK,
by navigating back do you use Back button of browser or do you use
explicit link (at the another page) to get back to the page with TextBoxes?
-- Teemu Keiski MCP, Microsoft MVP (ASP.NET), AspInsiders member ASP.NET Forum Moderator, AspAlliance Columnist http://blogs.aspadvice.com/joteke
"kai" <ka******@earthlink.net> wrote in message news:Ys*****************@newsread3.news.atl.earthl ink.net... Hi, Teemu Thanks for helping me. I read your page explanation. Yes, I visit completely another ASP.NET page, when I navigate back, data still ramain in the textboxs and radio button. Only password field data cleared.
Thanks Kai "Teemu Keiski" <jo****@aspalliance.com> wrote in message news:uj**************@TK2MSFTNGP11.phx.gbl... Hi,
disabling ViewState has no effect on TextBox..
Take a look at my blog post for an explanation http://blogs.aspadvice.com/joteke/ar...03/15/767.aspx
This relates to the posting behaviour (when page posts back to itself), but you said "come back to the same page". Are you visiting another
completely separate ASP.NET page and then return to the original Page containing TextBoxes and they still keep the state!?
-- Teemu Keiski MCP, Microsoft MVP (ASP.NET), AspInsiders member ASP.NET Forum Moderator, AspAlliance Columnist http://blogs.aspadvice.com/joteke
"kai" <ka******@earthlink.net> wrote in message news:IL*****************@newsread3.news.atl.earthl ink.net... Hi, All
I create an ASP.NET page, it contains FirstName textbox and LastName textbox. I setup "enableViewState=false" in page directive. When I
enter data in FirstName and LastName textbox, after I refresh the page or go to different page and come back to the same page, I find data entered in FirstName and LastName textbox are still there.
I think after setup "enableViewState=false" , we are not suppose to
see data in the textbox after we move to another page and come back?
Please help.
Thanks
Kai
Hi, Steven
Thank you very much, it helps a lot!
Kai
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:kE*************@cpmsftngxa06.phx.gbl... Hi Kai,
Does the "Explicit Link" means a hyperlink? If so I think this behavior is completely nothing related to the Page's viewstate. Because when we click
a link and navigator to a page, this page will be requested again from the server(just like we use response.redirect(page url)), that means it is a new request no relation with the former postback, so we can see all the data in it lost.
In addition, here are some refernce on ASP.NET's viewstate in MSDN: Taking a Bite Out of ASP.NET ViewState http://msdn.microsoft.com/library/en...001.asp?frame= true
#Maintaining State in a Control http://msdn.microsoft.com/library/en...ainingstateinc ontrol.asp?frame=true
ASP.NET ServerControl's life cycle on serverside: #Control Execution Lifecycle http://msdn.microsoft.com/library/en...rolexecutionli fecycle.asp?frame=true
Hope helps.
Regards,
Steven Cheng Microsoft Online Support
Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Get Preview at ASP.NET whidbey http://msdn.microsoft.com/asp.net/whidbey/default.aspx This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Carpe Diem |
last post by:
Hello I have an aspx page that loses Session("user") value after a few
minutes even after I set
<sessionState mode="InProc" cookieless="false" timeout="300"> in web.config
and wrote
function...
|
by: Steve Chatham |
last post by:
I am stuck on this. It ought to be a simple reason as to why this is
problematic, in that it works on smaller groups of data (say under 40
records), but doesn't on larger groups of records (40+)....
|
by: kai |
last post by:
Hi, All
I create an ASP.NET page, it contains FirstName textbox and LastName
textbox. I setup "enableViewState=false" in page directive. When I enter
data in FirstName and LastName textbox,...
|
by: Tony |
last post by:
Dear All,
When I run an example program on the
http://www.dotnetjunkies.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/datagrid1.src&file=VB\datagrid1.aspx&font=3
...
|
by: Nathan Sokalski |
last post by:
I recently converted some ASP.NET 1.1 projects of mine, created with Visual
Studio .NET 2003, to Web Application Projects in Visual Studio .NET 2005 so
that I could use ASP.NET 2.0 (All my ASP.NET...
|
by: Chicagoboy27 |
last post by:
All I am trying to find a solution for removing the ?returnUrl if a
user is not authenticated. I want to be redirect an unauthenticated
user to the login.aspx less the returnUrl.
Once they log...
|
by: trint |
last post by:
i have this in the html view:
<asp:TemplateField HeaderText ="Remove?">
<ItemTemplate>
<asp:CheckBox ID="removeSelect1" runat="server" />
</ItemTemplate>
<HeaderTemplate>
</HeaderTemplate>...
|
by: Gilbert Tordeur |
last post by:
Hello,
As most of my users use a slow WAN I always write aspx pages with
EnableViewState="false".
However, I remark that the RowCommand and the RowDeleting routines of my
GridView are not...
|
by: Gilbert Tordeur |
last post by:
Hello,
As most of my users use a slow WAN I always write aspx pages with
EnableViewState="false" to reduce the page size.
However, I remark that the RowCommand and the RowDeleting routines of...
|
by: justice750 |
last post by:
Hi All,
I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |