473,413 Members | 2,051 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Web site vs Web Project: scope difference?

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.

Aug 11 '07 #1
4 1727
On Aug 11, 6:40 am, olduncleamos <oldunclea...@yahoo.comwrote:
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.
Maybe you need to define the namespace

Either try to add

<%@ Import Namespace="NSHERE" %>

or

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

Hope this helps

Aug 11 '07 #2
On Aug 11, 4:17 am, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On Aug 11, 6:40 am, olduncleamos <oldunclea...@yahoo.comwrote:


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.

Maybe you need to define the namespace

Either try to add

<%@ Import Namespace="NSHERE" %>

or

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

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.


Aug 11 '07 #3
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

"olduncleamos" <ol**********@yahoo.comwrote in message
news:11*********************@d55g2000hsg.googlegro ups.com...
On Aug 11, 4:17 am, Alexey Smirnov <alexey.smir...@gmail.comwrote:
>On Aug 11, 6:40 am, olduncleamos <oldunclea...@yahoo.comwrote:


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.

Maybe you need to define the namespace

Either try to add

<%@ Import Namespace="NSHERE" %>

or

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

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.


Aug 11 '07 #4
On Aug 11, 3:36 pm, olduncleamos <oldunclea...@yahoo.comwrote:
On Aug 11, 4:17 am, Alexey Smirnov <alexey.smir...@gmail.comwrote:


On Aug 11, 6:40 am, olduncleamos <oldunclea...@yahoo.comwrote:
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.
Maybe you need to define the namespace
Either try to add
<%@ Import Namespace="NSHERE" %>
or
<a href="<%# NSHERE.PageHelper.GetLocation() %>'>
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.- Hide quoted text -

- Show quoted text -
BTW, the right syntax is

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

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

Aug 11 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Vipul Jain | last post by:
Can any one please tell me what is the difference between global scope of an variable and file scope of an variable. Vipul
8
by: lawrence | last post by:
I'm learning Javascript. I downloaded a script for study. Please tell me how the variable "loop" can have scope in the first function when it is altered in the second function? It is not defined...
5
by: pembed2003 | last post by:
Hi all, I am reading the book "C How to Program" and in the chapter where it discuss scope rule, it says there are four scopes for a variable: function scope file scope block scope...
3
by: Keith | last post by:
I have an IIS 6.0 web server hosting an ASP.NET 2.0 web site. Help files for the site are pure html. Is there some way to serve these html pages using the same ASP.NET web site? If so, how do I...
4
by: Per Bolmstedt | last post by:
(This question has been asked previously in this group, but I don't think it was ever really properly answered.) I want to use reflection - preferably - to find all Web Forms in my web site that...
3
by: Timbo | last post by:
This is a really weird one and very odd. I have written a web site using VS2005 and .Net 2.0, all works very well when running it locally. However when I publish it to my web server (hosted by...
4
by: Hafner Avi | last post by:
Hi, I am trying to find out what is the difference between Web-Site and Web-Application-Project in Visual Studio 2005 ? People – what do you recommend ?
6
by: =?Utf-8?B?d2lsbGlhbQ==?= | last post by:
Hi, I posted this in wrong group, so just re-post here. There are two ways to create web-based application or web service, from VS start page, click on File and New, two options you can choose,...
4
MMcCarthy
by: MMcCarthy | last post by:
http://bytes.com/images/howtos/projectscope_blocks.jpgAs a freelance IT consultant for over 10 years, I’ve come to appreciate well defined project scopes. A project scope is a common understanding...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.