Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

Web site vs Web Project: scope difference?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
olduncleamos - 11 Aug 2007 05:40 GMT
Hi all,

I am running into the following problem that I am just plain stuck.
Can't even find a starting point to look:

I originally had a "web site" created in VS2005. Within the site I
have a helper class (under the App_code directory) called PageHelper.
Within the class there are a bunch of static functions.

On most of the pages, I will have something like the following on the
HTML side:
<a href="<%# PageHelper.GetLocation() %>'>....

Now I am starting a Web Application project in VS2005 and thought I
would do something similar. But the above line is now giving me a
stubborn problem. The application will compile fine, but when I hit
the page, I will get an error message:
CS0103: The name 'PageHelper' does not exist in the current context

The code behind file have no problem calling the PageHelper class but
the inline code can't seem to see it. I have checked to make sure the
namespace is identical.

Any help will be greatly appreciated. I plain can't see a direction to
this problem.

Thanks in advance.
Alexey Smirnov - 11 Aug 2007 09:17 GMT
> Hi all,
>
[quoted text clipped - 23 lines]
>
> Thanks in advance.

Maybe you need to define the namespace

Either try to add

<%@ Import Namespace="NSHERE" %>

or

<a href="<%# NSHERE.PageHelper.GetLocation() %>'>

Hope this helps
olduncleamos - 11 Aug 2007 14:36 GMT
> > Hi all,
>
[quoted text clipped - 35 lines]
>
> Hope this helps- Hide quoted text -

Thanks so much! I added the <%@ Import Namespace... %> and it is
working now. I tried to full qualify the PageHelper class as you
suggested in the second option but that didn't work. Besides the page
class and the helper class are in the same namespace. I must be
missing something here.

Thanks again for your help.
Mark Fitzpatrick - 11 Aug 2007 15:17 GMT
The actual page designer surface though is not in the namespace you think it
is. It's expected to be in the same namespace and class as the codebehind is
since it's a partial class after all, but that's not exactly the case. You
may notice in some of the runtime errors that you'll see a different
classname that has the aspnet phrase in it. In other words, these other
calls tend to run within their own space.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

>> > Hi all,
>>
[quoted text clipped - 43 lines]
>
> Thanks again for your help.
Alexey Smirnov - 11 Aug 2007 16:01 GMT
> > > Hi all,
>
[quoted text clipped - 45 lines]
>
> - Show quoted text -

BTW, the right syntax is

<a href="<%= NSHERE.PageHelper.GetLocation() %>">

"<%=" equals to Response.Write and href must be closed with ( " )

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.