Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# PreviousPage指令出错_C#_Asp.net - Fatal编程技术网

C# PreviousPage指令出错

C# PreviousPage指令出错,c#,asp.net,C#,Asp.net,我在使用Webforms,C#,Vs 2013 我尝试使用上一页访问一个表单和另一个表单 因此,我将以下内容添加到第2页: <%@ PreviousPageType VirtualPath="~/Survey.aspx" %> 我得到 Error 31 The type name 'HousingSurvey' does not exist in the type 'HousingSurvey.HousingSurvey' HousingSurvey类在Survey.asp

我在使用Webforms,C#,Vs 2013

我尝试使用上一页访问一个表单和另一个表单

因此,我将以下内容添加到第2页:

<%@ PreviousPageType VirtualPath="~/Survey.aspx" %>
我得到

Error   31  The type name 'HousingSurvey' does not exist in the type 'HousingSurvey.HousingSurvey'
HousingSurvey类在Survey.aspx中定义

<%@ Page EnableEventValidation="false" MaintainScrollPositionOnPostback="true" Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Survey.aspx.cs" Inherits="HousingSurvey.HousingSurvey" %>

生成的方法的工作时间与前一页的工作时间一样长,因为前一页实际上是上述类型

如果上一页可以是另一种类型,则需要单独使用生成的方法,并使用自己的方法或属性进行健全性检查。这涵盖了上一页不是预期页面的情况。我有这种情况,例如,当用户在目标页面上更改语言时

以下是我的代码(在Target.aspx.cs中):


此代码显式地使用了
base.PreviousPage
getter属性和自定义检查,避免使用生成的方法。

生成的方法的工作时间与前一页的工作时间一样长,因为前一页确实属于所述类型

如果上一页可以是另一种类型,则需要单独使用生成的方法,并使用自己的方法或属性进行健全性检查。这涵盖了上一页不是预期页面的情况。我有这种情况,例如,当用户在目标页面上更改语言时

以下是我的代码(在Target.aspx.cs中):

此代码显式使用
base.PreviousPage
getter属性和自定义检查,避免使用生成的方法

<%@ Page EnableEventValidation="false" MaintainScrollPositionOnPostback="true" Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Survey.aspx.cs" Inherits="HousingSurvey.HousingSurvey" %>
/// <summary>
///     Gets the previous page, if it was an instance of the "MyPrevious.aspx" page.
/// </summary>
/// <remarks>This access is used for the access to data from the "MyPrevious.aspx" page.</remarks>
/// <value>
///     The previous page, if it was an instance of the "MyPrevious.aspx" page, null otherwise.
/// </value>
private MyPrevious CheckedPreviousPage {
    get {
        if (base.PreviousPage != null) {
            if (base.PreviousPage is MyPrevious) {
                return PreviousPage;
            }
        }
        return null;
    }
}
if ((CheckedPreviousPage != null) && (CheckedPreviousPage.IsCrossPagePostBack)) {
    //Cross page post, populating fields
    MyTextBox.Text = CheckedPreviousPage.SomeTextBox.Text;
}