473,802 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

QyeryString related questions..

Hi!

I'm building my portal and I found that some times I need to dinamically
generate address.

Since I have many modules and each could have it's own parameters in order
to preserve other's modules stuff I try to preserve
Query string:

string GetQueryString( )
{
string s = "";

foreach(string str in Request.QuerySt ring)
s += str + "=" + Request.QuerySt ring[str] + "&";

//If not empty then cut off last parameter:
if (s.Length != 0) s = s.Remove(s.Leng th-1, 1);
return s;
}

//add's parameter to passed query string. Or updates if was there.
string AddToQueryStrin g(string str_QueryString , string str_Param, string
str_Value)
{

}
Then I add my parameters. Each module does same thing and this way user will
expirience full state maintenance when browse within single "page"
My questions:

1. Is it something common? And if yes then my functions most likely already
in .NET. What are they?

2. I don't like to have same function in each module, how can I move it out?
I remember there was a class which don't have to be initialized. What is
this class? I would use it for my common functions.

Thanks!




Nov 17 '05 #1
5 1314
If you want to make it a static (Shared) function, just get the Request from
the HttpContext:

VB.Net:

Dim Request As System.Web.Http Request
If Not IsNothing(Syste m.Web.HttpConte xt.Current) then
Request = System.Web.Http Context.Current .Request
End If

C#:

System.Web.Http Request Request
if (System.Web.Htt pContext.Curren t != null)
Request = System.Web.Http Context.Current .Request;

Note: It would be best to avoid using Modules, or, if this is the case here,
referring to classes as Modules. Modules are really there for backwards
compatibility, and should be replaced with classes. You can put a public
static method into a public class, and the class doesn't need to be
instantiated to use the method. Any of the members of HttpContext can be
grabbed from a static method, including Server, Page, Request, Response,
Application, Session, and a number of other less-commonly-used members.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"Ivan Demkovitch" <i@d> wrote in message
news:OQ******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi!

I'm building my portal and I found that some times I need to dinamically
generate address.

Since I have many modules and each could have it's own parameters in order
to preserve other's modules stuff I try to preserve
Query string:

string GetQueryString( )
{
string s = "";

foreach(string str in Request.QuerySt ring)
s += str + "=" + Request.QuerySt ring[str] + "&";

//If not empty then cut off last parameter:
if (s.Length != 0) s = s.Remove(s.Leng th-1, 1);
return s;
}

//add's parameter to passed query string. Or updates if was there.
string AddToQueryStrin g(string str_QueryString , string str_Param, string str_Value)
{

}
Then I add my parameters. Each module does same thing and this way user will expirience full state maintenance when browse within single "page"
My questions:

1. Is it something common? And if yes then my functions most likely already in .NET. What are they?

2. I don't like to have same function in each module, how can I move it out? I remember there was a class which don't have to be initialized. What is
this class? I would use it for my common functions.

Thanks!



Nov 17 '05 #2
Thanks Kevin,

Thats what I need (because I think I need it)

I'm from desktop development and new to Web.

I wonder if this is what people do to preserve view state? Or is there
better way to do this.?

I refered to modules in my portal, this is actually Web controls.
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ub******** ******@TK2MSFTN GP12.phx.gbl...
If you want to make it a static (Shared) function, just get the Request from the HttpContext:

VB.Net:

Dim Request As System.Web.Http Request
If Not IsNothing(Syste m.Web.HttpConte xt.Current) then
Request = System.Web.Http Context.Current .Request
End If

C#:

System.Web.Http Request Request
if (System.Web.Htt pContext.Curren t != null)
Request = System.Web.Http Context.Current .Request;

Note: It would be best to avoid using Modules, or, if this is the case here, referring to classes as Modules. Modules are really there for backwards
compatibility, and should be replaced with classes. You can put a public
static method into a public class, and the class doesn't need to be
instantiated to use the method. Any of the members of HttpContext can be
grabbed from a static method, including Server, Page, Request, Response,
Application, Session, and a number of other less-commonly-used members.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
The more I learn, the less I know.

"Ivan Demkovitch" <i@d> wrote in message
news:OQ******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi!

I'm building my portal and I found that some times I need to dinamically
generate address.

Since I have many modules and each could have it's own parameters in order to preserve other's modules stuff I try to preserve
Query string:

string GetQueryString( )
{
string s = "";

foreach(string str in Request.QuerySt ring)
s += str + "=" + Request.QuerySt ring[str] + "&";

//If not empty then cut off last parameter:
if (s.Length != 0) s = s.Remove(s.Leng th-1, 1);
return s;
}

//add's parameter to passed query string. Or updates if was there.
string AddToQueryStrin g(string str_QueryString , string str_Param,

string
str_Value)
{

}
Then I add my parameters. Each module does same thing and this way user

will
expirience full state maintenance when browse within single "page"
My questions:

1. Is it something common? And if yes then my functions most likely

already
in .NET. What are they?

2. I don't like to have same function in each module, how can I move it

out?
I remember there was a class which don't have to be initialized. What is
this class? I would use it for my common functions.

Thanks!




Nov 17 '05 #3
> I wonder if this is what people do to preserve view state? Or is there
better way to do this.?
In some cases, yes, you can preserve state by using static members. There
are quite a few other ways to perserve state as well, such as using
ApplicationStat e, SessionState, HttpContext, files, database, etc. You need
to determine the most appropriate mechanism to use based upon the
requirement of the application regarding whatever it is you want to
preserve. Basic rule of thumb: Always use the mechanism with the smallest
necessary scope. Static members have totally global scope, so watch out!
I refered to modules in my portal, this is actually Web controls.
I suspected that, hence my alternate possibility ("or, if this is the case
here, referring to classes as Modules").

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"Ivan Demkovitch" <i@d> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. .. Thanks Kevin,

Thats what I need (because I think I need it)

I'm from desktop development and new to Web.

I wonder if this is what people do to preserve view state? Or is there
better way to do this.?

I refered to modules in my portal, this is actually Web controls.
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ub******** ******@TK2MSFTN GP12.phx.gbl...
If you want to make it a static (Shared) function, just get the Request

from
the HttpContext:

VB.Net:

Dim Request As System.Web.Http Request
If Not IsNothing(Syste m.Web.HttpConte xt.Current) then
Request = System.Web.Http Context.Current .Request
End If

C#:

System.Web.Http Request Request
if (System.Web.Htt pContext.Curren t != null)
Request = System.Web.Http Context.Current .Request;

Note: It would be best to avoid using Modules, or, if this is the case

here,
referring to classes as Modules. Modules are really there for backwards
compatibility, and should be replaced with classes. You can put a public
static method into a public class, and the class doesn't need to be
instantiated to use the method. Any of the members of HttpContext can be
grabbed from a static method, including Server, Page, Request, Response,
Application, Session, and a number of other less-commonly-used members.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
The more I learn, the less I know.

"Ivan Demkovitch" <i@d> wrote in message
news:OQ******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi!

I'm building my portal and I found that some times I need to dinamically generate address.

Since I have many modules and each could have it's own parameters in order to preserve other's modules stuff I try to preserve
Query string:

string GetQueryString( )
{
string s = "";

foreach(string str in Request.QuerySt ring)
s += str + "=" + Request.QuerySt ring[str] + "&";

//If not empty then cut off last parameter:
if (s.Length != 0) s = s.Remove(s.Leng th-1, 1);
return s;
}

//add's parameter to passed query string. Or updates if was there.
string AddToQueryStrin g(string str_QueryString , string str_Param,

string
str_Value)
{

}
Then I add my parameters. Each module does same thing and this way user
will
expirience full state maintenance when browse within single "page"
My questions:

1. Is it something common? And if yes then my functions most likely

already
in .NET. What are they?

2. I don't like to have same function in each module, how can I move
it out?
I remember there was a class which don't have to be initialized. What

is this class? I would use it for my common functions.

Thanks!





Nov 17 '05 #4
> preserve. Basic rule of thumb: Always use the mechanism with the smallest
necessary scope. Static members have totally global scope, so watch out!


Thanks!

This is only static functions, so I don't have to rewrite it every time.
I'm not going to store anything in public variables, only authentication. ..

public static works, but I need to include my class name every time I call
function.

Is there any way I could do it so I just call function?

Nov 17 '05 #5
In C#: using AssemblyName;
In VB.Net: Imports AssemblyName

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"Ivan Demkovitch" <i@d> wrote in message
news:O4******** ******@TK2MSFTN GP12.phx.gbl...
preserve. Basic rule of thumb: Always use the mechanism with the smallest necessary scope. Static members have totally global scope, so watch out!

Thanks!

This is only static functions, so I don't have to rewrite it every time.
I'm not going to store anything in public variables, only

authentication. ..
public static works, but I need to include my class name every time I call
function.

Is there any way I could do it so I just call function?

Nov 17 '05 #6

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

Similar topics

1
1506
by: John Smith | last post by:
Hello all: I have a few questions regarding ADO.NET data access: 1. I have a DataSet that gets populated w/several tables, but I would like to display a certain column in one of those tables by pulling the related records from another table. To put this clearer I have two tables in a database, one w/shipping info and one w/drivers. They are related by a driver id in each one. But how do I display
1
1062
by: Adam Knight | last post by:
Hi all, A couple of quick questions relating to datasets: Is one dataset in a given page generally used to bind all controls to db data? If a dataset object is to be used globally by all, is it best to use the 'New DataSet' declaration in PAGE_LOAD?
2
1159
by: Anthony Nystrom | last post by:
I have a mdi parent which has a control that I have attached. Within this control are the procedures I use to open mdi children. How do I explicitly maximize and minimize children rather than have them reopen as new. I have set a flag on a test of one and yes I can easily tell if the form is open, but how do I maximize it without the user having to select the maximize button. Rather I would like it to maximize when the user selects the...
13
12818
by: M.Siler | last post by:
Let me clarify from my last post. I am not using these 4 questions as the sole screening method. Currently in, the Tampa Bay area (Florida) there is an extreme shortage of C# developers. We have utilized just about every method known to man to find candidates, including employment firms (which I do not like to use, but when you're back in against the proverbial wall). With the employment firms they will send over just about anyone. So after...
0
4602
by: connectrajesh | last post by:
INTERVIEWINFO.NET http://www.interviewinfo.net FREE WEB SITE AND SERVICE FOR JOB SEEKERS /FRESH GRADUATES NO ADVERTISEMENT
102
5561
by: dreamznatcher | last post by:
Hello, I'm considering a career switch to a more database-related job, but need help on a few questions and issues. I'm a Computer Engineering graduate and have always felt most comfortable creating database- driven applications, preferably for web portals. 1. What are the most viable career options for me out there? What profile do I fit in? 2. What is the current job market/salary situation for database
0
1658
by: bsneddon | last post by:
Sorry cross post but no one answered my question on comp.language.python. I am a little confused about XQuery. I have read the tutorial on W3Schools site. It looks very powerful and like something I would like to use. The syntax doc("books.xml") from W2Scools site looks like it might be related to dom. I have read it is implemented in Saxon. I have seen several post related to Berkley DB XML 2. Is it related
8
7989
by: Krypto | last post by:
Hi, I have used Python for a couple of projects last year and I found it extremely useful. I could write two middle size projects in 2-3 months (part time). Right now I am a bit rusty and trying to catch up again with Python. I am now appearing for Job Interviews these days and I am wondering if anybody of you appeared for a Python Interview. Can you please share the questions you were asked. That will be great help to me.
2
1058
by: Max2006 | last post by:
Hi, Which newsgroup should I post my questions related to Team Foundation Server 2008? Thank you, Max
0
9699
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
9562
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
10536
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
10304
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
7598
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
5494
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
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
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.