473,651 Members | 2,917 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

New .net 2.0 syntax...namesp aces? Shared methods?

Hey guys

I had a site in .net 1.1 and have just moved it to .net 2.0.

A strange thing, in .net 1 when you create a project it puts it in a
namespace, in 2.0 it doesn't?

Also when in a namespace one form can't access methods in another, and when
not in a namespace same issue.

However a dll i made in my orignal with a namespace was fine.

So is this a new syntax thing, that in ,net 2.0 one forms code behind file
methods cannot access another forms codebehind class?

For example:

class Form 1 has method MyForm1Method()

class Form 2 has method MyForm2Method() ;

in class Form1 i used to be able to;

Form2 f2 = new Form2();
f2.MyForm2Metho d();

But now it can't find Form2.

Let us know if this is new syntax. I am guessing it is to ensure that all
shared methods across multiple forms are placed in a referenced dll giving
all forms access. Let me know.

D
Oct 17 '06 #1
5 1347
Daniel wrote:
A strange thing, in .net 1 when you create a project it puts it in a
namespace, in 2.0 it doesn't?
This is the default, but you can still wrap your classes in a namespace
if you like.
Also when in a namespace one form can't access methods in another, and when
not in a namespace same issue.
Have you checked that both the page class and the methods are public?

The way ASP.NET 2.0 works is that each page is compiled as needed. I'm
not sure if the code for the second form you are trying to access is
even guaranteed to be there. You should put all classes to be shared
by other pages either into App_Code or a different assembly.

As a side note, this sounds like a bad habit - why would you want to
call a method on a page from another page?

apathetic

Oct 17 '06 #2
Yes i a agree it is a bad habit. I now do it all via shared livrary classes
in dlls. Its old code i am bringing up to scratch that was made in stupid
deadlines.

What is App_Code? I haven't heard of that. Is it just a folder tha is
global? Should i drop all my cs files in there?

And yes classes are all public....when you say page class you mean the
codebehind cs file page yes? That class is public.

D
"apathetic" <ap************ *@gmail.comwrot e in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
Daniel wrote:
>A strange thing, in .net 1 when you create a project it puts it in a
namespace, in 2.0 it doesn't?

This is the default, but you can still wrap your classes in a namespace
if you like.
>Also when in a namespace one form can't access methods in another, and
when
not in a namespace same issue.

Have you checked that both the page class and the methods are public?

The way ASP.NET 2.0 works is that each page is compiled as needed. I'm
not sure if the code for the second form you are trying to access is
even guaranteed to be there. You should put all classes to be shared
by other pages either into App_Code or a different assembly.

As a side note, this sounds like a bad habit - why would you want to
call a method on a page from another page?

apathetic

Oct 17 '06 #3
Take a look at the web application projects. This project is more akin to
the VS.Net 2003 web application.
http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx

The VS 2005 Web site project is very different. One of the reasons you are
running into these issues is the code is not precompiled into a single dll.
It will end up as many dll files. You'll find that files within the same
directory may be able to reference eachother, but not files in another
directory. The Web application project was introduced because the change was
not working out for a significant number of users.

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Daniel" <Da*****@vestry online.comwrote in message
news:OK******** ******@TK2MSFTN GP04.phx.gbl...
Yes i a agree it is a bad habit. I now do it all via shared livrary
classes in dlls. Its old code i am bringing up to scratch that was made
in stupid deadlines.

What is App_Code? I haven't heard of that. Is it just a folder tha is
global? Should i drop all my cs files in there?

And yes classes are all public....when you say page class you mean the
codebehind cs file page yes? That class is public.

D
"apathetic" <ap************ *@gmail.comwrot e in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
>Daniel wrote:
>>A strange thing, in .net 1 when you create a project it puts it in a
namespace, in 2.0 it doesn't?

This is the default, but you can still wrap your classes in a namespace
if you like.
>>Also when in a namespace one form can't access methods in another, and
when
not in a namespace same issue.

Have you checked that both the page class and the methods are public?

The way ASP.NET 2.0 works is that each page is compiled as needed. I'm
not sure if the code for the second form you are trying to access is
even guaranteed to be there. You should put all classes to be shared
by other pages either into App_Code or a different assembly.

As a side note, this sounds like a bad habit - why would you want to
call a method on a page from another page?

apathetic


Oct 17 '06 #4
1. ASP.Net 2005 website projects have several "special folders."
Search google for App_Code and App_Data. Shared code pretty much needs
to go in app code in order to be accesible.

2. In 2005, every subfolder is compiled into a separate assembly,
regardless of namespace. Before, in 2003, it was one assembly per
namespace (or was it one assembly for the whole site?). So,
unfortunately, there will be scoping issues when upgrading from 1.x to
2.0 because files are no longer in the same assembly.

3. As Mark F. mentioned above, enough people complained about the new
application model that MS released a "workaround " to make your 2005
"web site apps" behave more like 2003 "web projects". I've used it and
it works... but I try not to.. I think it's better to evolve and adapt.

4. I forgot to mention this... and this is huge... in 2005, you no
longer have a "project" that contains .aspx files. You have a
"website" that maps to a folder on your hard drive. Whatever files are
in your folder are considered "in your website." To remove a file, you
need to delete it. There's no concept of "adding/removing" files from
a project. I know I didn't explain this very well.

Oct 18 '06 #5
Ok thanks guys that explains A LOT of things. Ok so when i upload my site i
upload the full site directory.

The scoping issues, ok i see why people moand, but i agree evolve and adapt
always best measure.

Thanks for help

"Daniel" <Da*****@vestry online.comwrote in message
news:OO******** *****@TK2MSFTNG P05.phx.gbl...
Hey guys

I had a site in .net 1.1 and have just moved it to .net 2.0.

A strange thing, in .net 1 when you create a project it puts it in a
namespace, in 2.0 it doesn't?

Also when in a namespace one form can't access methods in another, and
when not in a namespace same issue.

However a dll i made in my orignal with a namespace was fine.

So is this a new syntax thing, that in ,net 2.0 one forms code behind file
methods cannot access another forms codebehind class?

For example:

class Form 1 has method MyForm1Method()

class Form 2 has method MyForm2Method() ;

in class Form1 i used to be able to;

Form2 f2 = new Form2();
f2.MyForm2Metho d();

But now it can't find Form2.

Let us know if this is new syntax. I am guessing it is to ensure that all
shared methods across multiple forms are placed in a referenced dll giving
all forms access. Let me know.

D

Oct 18 '06 #6

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

Similar topics

699
33862
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
8
3341
by: Jan van Veldhuizen | last post by:
The UPDATE table FROM syntax is not supported by Oracle. I am looking for a syntax that is understood by both Oracle and SqlServer. Example: Table1: id name city city_id 1 john newyork null
2
1256
by: Raymond Lewallen | last post by:
It could help if you understood the project I work on a bit, but I can't tell you anything about it, so do the best you can under that pretense. Lets say you have a global assembly supporting multiple applications. In that assembly, you have mass amounts of classes classified as such: functions that get data, instantiated functions that process large amounts of data, shared functions that process small bits of information, like some...
1
1328
by: Andy Lomax | last post by:
I'm converting a library I've written so that all my code is in namespace 'foo' (previously all my external symbols had a 'foo_' prefix; I'm new to C++). Question: my source files now have a 'using namespace foo' in them, and I refer to all my library classes/methods/etc without a 'foo::' qualifier. Is this a good idea? If I access my own ("private" to myself) class 'bar' in the library, and I distribute the code as a shared lib, will...
8
4322
by: tom | last post by:
I am new to SQL administration. >From a list of IDs that are the primary key in one table (i.e. Customer Table), I want to make changes in tables that use those IDs as a foreign key. Basically I want to say: If fk_ID is in list then do these statements to that record
5
2364
by: M Shafaat | last post by:
Hi, I want to develop a number of generic components which I intend to use in different applications. Is it a good idea to put all these generic components in one and the same namespace, e.g. named GenApplCtrls, without any regard to whether or not the components have any functionality in common? Which principles should be considered when deciding which classes to belong to a namespace?
44
3350
by: petermichaux | last post by:
Hi, I have been using the following line of code to create an object called "Serious" if it doesn't already exist. if (Serious == null) {var Serious = {};} This works in the scripts I use it but but www.jslint.com is not happy with me.
6
2469
by: douglass_davis | last post by:
Is the whole System namespace automatically imported?
5
1595
by: Simon | last post by:
I have problem with namespaces. I have a program that consumes the web service and has for instance names space nsProgram. In this program I have defined several classes that I use for storing and handling internal information. Than I have web service, that also uses the same classes (I included the file as linked external resource). I included this web service as web reference and used name wsWeb. When I am trying to call the web...
0
8277
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8803
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8700
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8465
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5612
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4285
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1910
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.