Page.PreviousPage.FindControl为NULL [英] Page.PreviousPage.FindControl is NULL
问题描述
我正在通过两个不同的页面访问Test.aspx。像这样的东西:
Page1.aspx -------> Test.aspx< -------- Page2.aspx
我正在IE7中对此进行测试,其中 Request.UrlReferrer.AbsoluteUri
不起作用。在IE 8+中,它可以工作。到目前为止,我尝试过的所有方法都没有奏效,并且无法推动我坚果。
我还尝试在Page1.aspx中放置一个隐藏的文本框,以便我可以看看控件文本框是否可用,如果可以的话,我知道我来自第1页还是第2页。该代码无法正常工作:
var hidden = Page.PreviousPage.FindControl( tbhidden);
'tbhidden'是这样的:< asp:textbox ID = tbhidden runat = server visible = false />
您将如何解决此问题?
正常情况下,启动浏览器后购买的第一页的UrlReferrer是空白的吗?
如果使用Server.Transfer命令进行服务器端重定向,则只能使用Page.PreviousPage对象。
破坏问题下来
如果您使用锚点定位到测试页,请在第1页和第2页中向其添加参数
< a href = test.aspx?from = page1 ...>
并使用
Request.QueryString [ from]
在测试页中进行选择如果您使用的是帖子,请修改第1页和第2页中的表单操作
< form action = test.aspx?from = page1 ...>
这将再次检查您是否来自正确的页面。
另一个个好技巧是下载名为 Fiddler的工具,该工具拦截网站帖子,并给出所有引荐值和出现的页面请求的格式良好的细分。 / p>
I am accessing Test.aspx through two different pages. Something like this:
Page1.aspx -------> Test.aspx <-------- Page2.aspx
I am testing this in IE7 where Request.UrlReferrer.AbsoluteUri
is not working. In IE 8+ it works. Nothing I tried is working so far and its driving me nuts.
I also tried putting a hidden textbox in Page1.aspx so that I can see if the control textbox is available, if it is then I know I am coming from Page1 or else Page2. This code is not working:
var hidden = Page.PreviousPage.FindControl("tbhidden");
'tbhidden' is this: <asp:textbox ID="tbhidden" runat="server" visible = "false"/>
How would you crack this problem?
Normally the UrlReferrer will be blank for the first page bought up when a browser is started?
You can only use the Page.PreviousPage object if you are doing a server side redirect using the Server.Transfer command
Breaking the problem down
If you are using anchors to get to the test page then add a parameter to it in page1 and 2
<a href="test.aspx?from=page1 ...>
and pick it up in the test page using Request.QueryString["from"]
If you are using a post then amend the form action in page1 and 2
<form action="test.aspx?from=page1 ...>
This will double check that you are coming from the correct page.
Another good tip is to download the tool called "Fiddler", it intercepts the website posts and gives a nicely formatted breakdown of all the referral values and page requests that occur.
这篇关于Page.PreviousPage.FindControl为NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!