如何以编程方式设置" previousPageType VirtualPath" (对于QUOT; Server.Transfer的"从多个页面一页)? [英] How to programmatically set "PreviousPageType VirtualPath" (for "Server.Transfer" to one page from multiple pages)?

查看:342
本文介绍了如何以编程方式设置" previousPageType VirtualPath" (对于QUOT; Server.Transfer的"从多个页面一页)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有一对夫妇使用网页上显示一个页面 Server.Transfer的(例如,如果用户导航到Page 1或2页 - 它会在两种情况下,他出示第3页)。我这样做,因为页面是非常相似的。

I want to have one page shown for a couple of pages using Server.Transfer (e.g. if the user navigates to page1 or page2 - it will, in both cases, show him page3). I am doing that because the pages are very similar.

不过,也有一对夫妇它们之间的差异,我想借此获得发送页面的公共属性的保健(如第1页第2页或)如图所示的这里的第四个选项MSDN

However, there are a couple of differences between them, which I want to take care of getting the public properties of the sending page (e.g. page1 or page2) as shown here on MSDN in the fourth option.

但是,这需要 previousPageType VirtualPath 设置为正确的页面 - 这可能是几个中的一个(例如第1页第2页或)。我该怎么做呢?

But that needs the PreviousPageType VirtualPath to be set to the correct page - which might be one of several (e.g. page1 or page2). How do I do that?

编辑:这是一个Web应用程序项目

It's a web application project.

推荐答案

这是使用 Object.GetType()方法,从中找出问题乌尔另一种方式页面调用 Server.Transfer的方法。

This is an alternate way to ur problem using Object.GetType() method to find out from which page you call server.transfer method.

这是在Page_Load中code第3页

    Object prePage=PreviousPage;
    String gotprePage=prePage.GetType().ToString();
    if (gotprePage == "ASP.crosspage3_aspx")
    {
        //now call properties specific to crosspage3.aspx page
        // prePage.GetType().GetProperty("your_property").
        //GetValue(objPreviousPage, null).ToString();
    }
    else
    {
        if (gotprePage == "ASP.crosspage4_aspx")
        {
            //now call properties specific to crosspage4.aspx page
        }
    }

这篇关于如何以编程方式设置" previousPageType VirtualPath" (对于QUOT; Server.Transfer的"从多个页面一页)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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