如何获取页面以维持控制状态? [英] How do I get a page to maintain control states?

查看:50
本文介绍了如何获取页面以维持控制状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与上面的主题相同,处理后退

按钮。我无处可去。我最近的样子是给我留下的样品




<%@ Page Language =" vb" %>

<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.0 Transitional // EN">

< html>

< head>

< / head>

< body>

< form runat =" server" ; ID =" Form1"

< p>

& nbsp;< asp:TextBox id =" TextBox1"

runat =" server">< / asp:TextBox>

< / p>

< p>

& ;< asp:Button id =" Button1" runat =" server"

Text =" Button">< / asp:Button>

< / p>

< / form>

< / body>

< / html>


1 - 加载页面,输入文本框中的内容。

2 - 点击提交

3 - 点击返回

4 - 您输入的字符串仍然存在。


当我将这段代码全部放入新的.aspx页面并运行

时,按下后退按钮后文本框为空。


为什么,我该如何预防呢? (在我完全疯了之前)


谢谢!

This is the same topic as the thread above, "Dealing with the Back
button". I''m getting nowhere. The closest I''ve come is a sample left
for me:

<%@ Page Language="vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
</head>
<body>
<form runat="server" ID="Form1">
<p>
&nbsp;<asp:TextBox id="TextBox1"
runat="server"></asp:TextBox>
</p>
<p>
&nbsp;<asp:Button id="Button1" runat="server"
Text="Button"></asp:Button>
</p>
</form>
</body>
</html>

1 - Load the page, enter something in the text box.
2 - Hit submit
3 - Click Back
4 - The string you entered remains.

When I put this code, in its entirety, into a new .aspx page and run
it, the textbox is blank after hitting the back button.

Why, and how can I prevent it? (before I go completely insane)

Thanks!

推荐答案

我不喜欢看看你在第1点到第4点与后来的

情景之间有什么区别(如果你在使用后退按钮之前使用了提交,则不清楚)。


IMO :

- 如果出现问题,我会用错误

消息重新显示整个表单,这样用户甚至不必使用后退按钮。保持

介意你会依赖客户端行为,用户可以通过更改其IE设置来改变(通过更改其IE设置)。

- 现在我有你在第1点到第4点描述的行为。这可能是你的缓存有问题吗?我会尝试将日期/时间信息添加到

页面,以查看带有空白字段的页面是否来自IE缓存,或者IE

是否再次从服务器。它也可以是IE设置。现在

它看起来很像当你使用后退按钮时,IE再次获取页面

(AFAIK它也是旧IE版本的行为,你的版本是你的

使用)。


祝你好运。


Patrice

-


汤姆威尔逊 <叶******* @ nospam.com> écritdansle message de

news:pv ******************************** @ 4ax.com ...
I don''t see what difference you make between point 1 to 4 and the later
scenario (not clear if you used submit before using the back button).

IMO :
- if something is wrong I would redisplay the whole form with the error
message so that the user doesn''t even have to use the back button. Keep in
mind that you would rely here on a client side behavior that the user could
have altered (by changing its IE settings).

- for now I have the behavior you described in point 1 to 4. Could it be a
problem with your cache ? I would try to add a date/time information to the
page to see if the page with blank fields comes from the IE cache or if IE
gets it once again from the server. It could be also a IE settings. For now
it looks liike that when you using the back button, IE gets the page again
(AFAIK it was also the behavior on old IE releases, whcih version are you
using).

Good luck.

Patrice
--

"Tom wilson" <ye*******@nospam.com> a écrit dans le message de
news:pv********************************@4ax.com...
这与上面的主题相同,处理后退
按钮。我无处可去。我最接近的是给我留下的一个样本:

<%@ Page Language =" vb" %>
<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.0 Transitional // EN">
< html>
< head>
< / head>
< body>
< form runat =" server" ID =" Form1"
< p>
& nbsp;< asp:TextBox id =" TextBox1"
runat =" server">< / asp:TextBox>
< / p>
< p>
& nbsp;< asp:Button id =" Button1" runat =" server"
Text =" Button">< / asp:Button>
< / p>
< / form>
< /正文>
< / html>

1 - 加载页面,在文本框中输入内容。
2 - 点击提交
3 - 单击返回
4 - 您输入的字符串仍然存在。

当我将此代码全部放入新的.aspx页面并运行
时,文本框在打完背后是空白的按钮。

为什么,我该如何预防呢? (在我完全疯了之前)

谢谢!
This is the same topic as the thread above, "Dealing with the Back
button". I''m getting nowhere. The closest I''ve come is a sample left
for me:

<%@ Page Language="vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
</head>
<body>
<form runat="server" ID="Form1">
<p>
&nbsp;<asp:TextBox id="TextBox1"
runat="server"></asp:TextBox>
</p>
<p>
&nbsp;<asp:Button id="Button1" runat="server"
Text="Button"></asp:Button>
</p>
</form>
</body>
</html>

1 - Load the page, enter something in the text box.
2 - Hit submit
3 - Click Back
4 - The string you entered remains.

When I put this code, in its entirety, into a new .aspx page and run
it, the textbox is blank after hitting the back button.

Why, and how can I prevent it? (before I go completely insane)

Thanks!



"> - 如果出现问题,我会重新显示整个表格带有

错误信息,这样用户甚至不必使用后面的

按钮。


这听起来合乎逻辑,不是吗?我的主要应用就是这样。你得到你的表格

,填写并提交。该页面返回浏览器

,每个错误控件上方都有红色错误文本。它是一件艺术品。

您可以反复提交,直到所有错误消失。我很自豪。


但是在这个过程中点击回来,即使在5次提交后,

页面也会返回空白。来吧,你知道有人会点击

后退按钮并打电话给我,生气。


所以我按照下面的建议尝试了你的时间示例:


- 加载表格。时间是:2:53:12

- 输入文字,提交

- 时间是2:53:33

- 点击返回 ;

- 时间是:2:53:12


我假设页面来自IE的缓存导致时间相同。如果它来自服务器的时间会过去

2:53:33,对吧?


所以这意味着... asp.net页面是不能保持状态吗?

:)


或者IE重新加载页面时会以某种方式查杀页面状态

从它的缓存?


没有任何意义。


(答复的答案!)



2005年2月16日星期三20:27:11 +0100,Patrice < no **** @ nowhere.com>

写道:
">- if something is wrong I would redisplay the whole form with the
error message so that the user doesn''t even have to use the back
button."

That sounds logical, doesn''t it? My main app works this way. You get
your form, fill stuff out and submit. The page returns to the browser
with red error texts above each ''errored'' control. Its a work of art.
You can submit repeatedly until all errors disappear. I''m proud.

But click back anywhere during this process, even after 5 submits, the
page is returned blank. Come on, you know SOMEbody is going to click
the back button and call me up, pissed.

So I tried your time example as suggested below:

- Load form. Time is: 2:53:12
- Enter text, submit
- Time is 2:53:33
- Click "Back"
- Time is: 2:53:12

I assume the page is coming from IE''s cache cause the time is the same
when going back. If it came from the server the time would be past
2:53:33, right?

So this means... asp.net pages are not capable of maintaining state?
:)

Or that IE is somehow killing the page state when it reloads the page
from its cache?

Nothing is making any sense.

(thx for the reply!)


On Wed, 16 Feb 2005 20:27:11 +0100, "Patrice" <no****@nowhere.com>
wrote:
我看不出你在1到4点和后来的情况(不清楚你是否在使用后退按钮之前使用了提交)。

IMO:
- 如果出现问题,我会重新显示整个表单并显示错误
消息,以便用户甚至不必使用后退按钮。请记住,您将依赖于客户端可能已更改的客户端行为(通过更改其IE设置)。

- 现在我有这种行为你在第1点到第4点中描述过。这可能是你的缓存问题吗?我会尝试在
页面添加日期/时间信息,以查看带有空白字段的页面是否来自IE缓存,或者IE是否从服务器再次获取它。它也可以是IE设置。现在
看起来很像当你使用后退按钮时,IE再次获取页面
(AFAIK它也是旧IE版本的行为,你使用的版本是什么)。<祝你好运。

Patrice
I don''t see what difference you make between point 1 to 4 and the later
scenario (not clear if you used submit before using the back button).

IMO :
- if something is wrong I would redisplay the whole form with the error
message so that the user doesn''t even have to use the back button. Keep in
mind that you would rely here on a client side behavior that the user could
have altered (by changing its IE settings).

- for now I have the behavior you described in point 1 to 4. Could it be a
problem with your cache ? I would try to add a date/time information to the
page to see if the page with blank fields comes from the IE cache or if IE
gets it once again from the server. It could be also a IE settings. For now
it looks liike that when you using the back button, IE gets the page again
(AFAIK it was also the behavior on old IE releases, whcih version are you
using).

Good luck.

Patrice






你没有:

<%@ Page EnableViewState =" True" %。

位于.aspx页面的顶部。


你的确有:

<%@ Page Language = QUOT; VB" %>


所以只需像这样添加EnableViewState:

<%@ Page Language =" VB"的EnableViewState = QUOT;真" %>


这将使您的页面能够保留表单信息。

You do not have:
<%@ Page EnableViewState="True" %>
at the top of your .aspx page.

You do have:
<%@ Page Language="vb" %>

So just add on the EnableViewState like this:
<%@ Page Language="VB" EnableViewState="True" %>

That will enable your page to keep the form information.


这篇关于如何获取页面以维持控制状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆