【问题标题】:IsPostBack does not exist in current contextIsPostBack 在当前上下文中不存在
【发布时间】:2015-07-27 15:54:13
【问题描述】:

所以基本上我需要在我的 windows 窗体 c# 应用程序中进行 if(!IsPostBack) 检查,因为在从文本框中获取值后,一旦它不再获取该值而是给出 null。但是我收到了错误。错误:

The name IsPostBack does not exist in the current context

我有:

using System.Web.UI;

所以我不确定为什么会这样。任何见解或解决方案将不胜感激,谢谢。

这是我的代码:

        if(!IsPostBack)
            System.Console.WriteLine("Text: " + textBox2.Text);
            MakeSureFieldIsFilledIn errormessagefieldempty = new MakeSureFieldIsFilledIn();
            errormessagefieldempty.ShowDialog();
        }

【问题讨论】:

  • IsPostBack 是一个 WebForms 概念,而不是 WinForms。在桌面环境中,您永远不会发出 POST。

标签: c# winforms ispostback


【解决方案1】:

根据您想要执行的操作,您应该将此 sn-p 移至您的事件处理程序。

【讨论】:

  • 我主张使用 ErrorProvider 而不是等待“提交”数据
  • 那也行。我只是在建议 WinForms 范例中最接近的选项。
猜你喜欢
  • 2023-03-30
  • 2020-03-10
  • 2017-06-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多