473,672 Members | 2,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

simple namespace question

I have a method that takes a string, formats it and returns it
I want to use this in multiple ASP.NET pages, by putting it in a namespace and using that in each asp.net page

What I don't understand is how to write that namespace so that I can reference that method elsewhere by simply writing
string Message = "Hello world";
string newstring = MyNamespace.MyM ethod(Message)

so I can call the method without having to create a new objec

Thankyou, Katie.
Nov 18 '05 #1
3 1107
You are talking about static(shared in vb.net) method which allow to execute
method without need in object been created.
example:

class MyClass
{
string static MyMethod(string Input)
{
....
return ...;
}
}

using:
string Message = "...";
string newstring = MyClass.MyMetho d(Message);
HTH

"Katie S" <an*******@disc ussions.microso ft.com> wrote in message
news:82******** *************** ***********@mic rosoft.com...
I have a method that takes a string, formats it and returns it.
I want to use this in multiple ASP.NET pages, by putting it in a namespace and using that in each asp.net page.
What I don't understand is how to write that namespace so that I can reference that method elsewhere by simply writing : string Message = "Hello world";
string newstring = MyNamespace.MyM ethod(Message);

so I can call the method without having to create a new object

Thankyou, Katie.

Nov 18 '05 #2
Mmhh i am very puzzled by your question as it seems you speak about 2
totally different things.

If you want to import a namespace in your aspx page, at the top just put
something like :

<%@ Import namespace="MyNa meSpace" %>

But if you want to do :
"so I can call the method without having to create a new object "
as you say in your message, then the method need to be static (shared in VB)

You will call that method like :
Myclass.MyMetho d();

No need to specify the full namespace as you can import it as i showed you.

Best regards,

Francois
"Katie S" <an*******@disc ussions.microso ft.com> wrote in message
news:82******** *************** ***********@mic rosoft.com...
I have a method that takes a string, formats it and returns it.
I want to use this in multiple ASP.NET pages, by putting it in a namespace and using that in each asp.net page.
What I don't understand is how to write that namespace so that I can reference that method elsewhere by simply writing : string Message = "Hello world";
string newstring = MyNamespace.MyM ethod(Message);

so I can call the method without having to create a new object

Thankyou, Katie.

Nov 18 '05 #3
Hi Katie,

Namespaces have no methods, they are only a way to easily identify
classes and avoid collision between classes name. Instead you could
create a class with a static method so, when you want to use it, you
don't have to create an instance of it.

HTH,

Stefano Mostarda MCP
Rome Italy

Katie S wrote:
I have a method that takes a string, formats it and returns it.
I want to use this in multiple ASP.NET pages, by putting it in a namespace and using that in each asp.net page.

What I don't understand is how to write that namespace so that I can reference that method elsewhere by simply writing :
string Message = "Hello world";
string newstring = MyNamespace.MyM ethod(Message);

so I can call the method without having to create a new object

Thankyou, Katie.

Nov 18 '05 #4

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

Similar topics

22
3283
by: lokman | last post by:
Hi, In the following code, can someone tell me the difference between *p++ and p++ ? I can see both achieve the same result. Thanks a lot !
7
1347
by: Mark Prenter | last post by:
Hi all, I'm fairly new to .NET and I haven't done much in C++ before, nothing complex anyway, but I have a pretty good understanding of programming in general. What I'm trying to do is create a .DLL that contains a lot of the functions and classes that I normally use. I've followed the examples from http://www.c-sharpcorner.com/2/pr12.asp which contains a pretty good example of creating a simple .DLL. Even though the example is in C#,...
2
8388
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when submitting the form to update the database. The server doesn't have the client side value any more. It seems to me that as I begin to write the client side javacript code for form validation and client side editing capabilities in order to save...
7
1149
by: SL | last post by:
Could someone direct to a simple explanation of how to use MS Visual Studio 2003 to design .aspx code? This code works if pasted into notepad and run as an .aspx file: <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OleDb" %> <script language="vb" runat="server"> Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs) Dim objConnection As OleDBConnection Dim objCommand As OleDBDataAdapter
6
2336
by: Paul | last post by:
Hi All, Framework 1.1 listbox control unable to DataBind I've been googling for an answer to this query that appears quite a lot, but none, it seem, answers my problem directly. I am populating a listbox with an array of very simple "Country" objects via a WebService. The Country class contains CountryID,TLDs and Name properties each of which have a getter and setter (I found that properties without
3
1506
by: Marco T. | last post by:
Hi all, why the former code fragment works and the latter doesn't? ============= //CORRECT CODE: namespace ciao { class A{};
3
2325
by: Chrism2671 | last post by:
I'm new to XSLT/XML and I have a very simple, quick question. i've been trying to convert simple xml files into CSV files and have made a simple XSLT template using the w3 tutorials, but it doesn't seem to display anything. It does display plain text I enter into the templates, the value-of tags just render whitespace. If anybody can write a template of just a few lines just to demonstrate how to get it to display something from this XML...
3
1756
by: Steven Edison | last post by:
I have a split container on my form, from within one of them I wish to reach the main from of the app. I'm having problems with the headers and namespaces. I want something like this: //within right pane form ABCForm^ abcForm = (ABCForm^)Application::OpenForms; abcForm->ExecutePublicFunction();
4
1354
by: =?Utf-8?B?SmFtZXMgUGFnZQ==?= | last post by:
Am i missing somthing simple? I can't access any of the profile names in my code behind i.e; textBox1.text = Profile.test = "some text" here's the web.config: <?xml version="1.0"?> <configuration>
0
8502
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8844
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
8638
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
8696
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6254
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5720
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
4438
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2836
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
2
1834
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.