Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.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# 回邮怎么复位?_C# - Fatal编程技术网

C# 回邮怎么复位?

C# 回邮怎么复位?,c#,C#,让我详细说明一下。。。我有下面的代码,有一个Page_Init(我仍然不明白为什么它会多次触发,但那是另一个故事),还有一个Page_加载,我正在检查“isPostBack”。。。当我使用我的控件、单选按钮和下拉列表以及按钮时,一切都很好;但是,如果我按下该键,即使是偶然按下,“isPostBack”也会重置为False。我做错了什么?此外,我的AutoEventWireup=“true”。 此外,这是一个.ascx文件 受保护的无效页_init(对象发送方,事件参数e) { 您正在检查IsPo

让我详细说明一下。。。我有下面的代码,有一个Page_Init(我仍然不明白为什么它会多次触发,但那是另一个故事),还有一个Page_加载,我正在检查“isPostBack”。。。当我使用我的控件、单选按钮和下拉列表以及按钮时,一切都很好;但是,如果我按下该键,即使是偶然按下,“isPostBack”也会重置为False。我做错了什么?此外,我的AutoEventWireup=“true”。 此外,这是一个.ascx文件

受保护的无效页_init(对象发送方,事件参数e) {


您正在检查
IsPostBack
,但在检查之前仍在执行所有重置!然后检查没有任何区别,因为它是一个空的条件块!您应该执行以下操作:

protected void Page_Load(object sender, EventArgs e)
{
    if(!IsPostBack)
    {
        // All the initial setup that you don't want to do again goes here.
    }

    // All the stuff you want to do on first load AND PostBack goes here.
}

请确保。

是的,可能这里有一个排序问题。这让我发疯了,我忘了提到我使用的是asp:Panels,我想可能这种技术不正确technique@PaulT.Rykiel面板没有问题。你只需要了解页面加载生命周期。谢谢你…我很感激
protected void Page_Load(object sender, EventArgs e)
{
    if(!IsPostBack)
    {
        // All the initial setup that you don't want to do again goes here.
    }

    // All the stuff you want to do on first load AND PostBack goes here.
}