0

So basically I need a if(!IsPostBack) check in my windows form c# application because after grabbing a value from a textbox once it is no longer grabbing that value and instead giving null. However I am getting the error. The error:

The name IsPostBack does not exist in the current context

I have:

using System.Web.UI;

So i'm not sure why this is happening. Any insight or solutions would be greatly appreciated, thanks.

Here is my code:

        if(!IsPostBack)
            System.Console.WriteLine("Text: " + textBox2.Text);
            MakeSureFieldIsFilledIn errormessagefieldempty = new MakeSureFieldIsFilledIn();
            errormessagefieldempty.ShowDialog();
        }
Babak Naffas
  • 12,395
  • 3
  • 34
  • 49
Brandan B
  • 464
  • 2
  • 6
  • 21

1 Answers1

0

Based on what it sounds like you're trying to do, you should move this snippet to your event handler.

Babak Naffas
  • 12,395
  • 3
  • 34
  • 49
  • 1
    I'd argue for using the [ErrorProvider](https://msdn.microsoft.com/en-us/library/system.windows.forms.errorprovider(v=vs.110).aspx) rather than waiting to "Submit" the data – Conrad Frix Jul 27 '15 at 16:06
  • That would work too. I was just suggesting the closest option in the WinForms paradigm. – Babak Naffas Jul 27 '15 at 17:44