views:

41

answers:

3

Never seen this before in ASP.NET development. I'm trying to refactor out 40 single-page ASP.NET pages to code-behind style.

What does this code do?

// Validate required parameters (if "new", then nothing is required)
if (!this.IsNew())
{
  if (string.IsNullOrEmpty(_billId))
  {
    responseErrorNo = 4;
    Utils.SendError(respErrNum);
  }
}

Its on a single-page design ASP.NET page in the block in the Page_Load method.

On a code-behind page this code ( .IsNew) is not recognized. What am I missing here? Is there an MSDN page on IsNew of the "page"?

update Ok. This is my dumbkoff move of the day. There was a little method hidding at the bottom of the server-side was protected bool IsNew()

see comments about the inheritance point. http://msdn.microsoft.com/en-us/library/015103yb.aspx

+2  A: 

Have you done a search through all the source files for IsNew?

Some possibilities
1. This is a method inherited from a base class, if you have one of course
2. IsNew might be an extension method. http://msdn.microsoft.com/en-us/library/bb383977.aspx
3. IsNew is a member of the class

Chris Taylor
+1  A: 

Hey,

If your code-behind file inherits from a custom page class, as in a class like PageBase instead of the standard System.Web.UI.page, the IsNew could be in there, and maybe your page needs to implement that... ALtneratively, it could be an extension method for the page class, and your missing the namespace reference to include it...

HTH.

Brian
single-page design can't inherit from a custom class. There is no class declaration inside the <script runat="server"></script>This is part of the reason I'm changing the design.
tyndall
@Page directive has Inherits attribute; can't you have it inherit from a base class using this by setting it to a property? Thought I saw some examples of this, found one commenter who said it was a pain though, I would rewrite it too if I had the chance :-)
Brian
+1  A: 

This is puzzling as the System.Web.UI.Page class definitely has no IsNew() method. The only way you would get that is if the page is inheriting from a base page, or perhaps if it there is an extension method that extends Page.

Can you right-click the method in Visual Studio and find the definition?

Dan Diplo