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.QueryString)
s += str + "=" + Request.QueryString[str] + "&";
//If not empty then cut off last parameter:
if (s.Length != 0) s = s.Remove(s.Length-1, 1);
return s;
}
//add's parameter to passed query string. Or updates if was there.
string AddToQueryString(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! 5 1294
If you want to make it a static (Shared) function, just get the Request from
the HttpContext:
VB.Net:
Dim Request As System.Web.HttpRequest
If Not IsNothing(System.Web.HttpContext.Current) then
Request = System.Web.HttpContext.Current.Request
End If
C#:
System.Web.HttpRequest Request
if (System.Web.HttpContext.Current != null)
Request = System.Web.HttpContext.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****************@TK2MSFTNGP09.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.QueryString) s += str + "=" + Request.QueryString[str] + "&";
//If not empty then cut off last parameter: if (s.Length != 0) s = s.Remove(s.Length-1, 1); return s; }
//add's parameter to passed query string. Or updates if was there. string AddToQueryString(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!
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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ub**************@TK2MSFTNGP12.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.HttpRequest If Not IsNothing(System.Web.HttpContext.Current) then Request = System.Web.HttpContext.Current.Request End If
C#:
System.Web.HttpRequest Request if (System.Web.HttpContext.Current != null) Request = System.Web.HttpContext.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****************@TK2MSFTNGP09.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.QueryString) s += str + "=" + Request.QueryString[str] + "&";
//If not empty then cut off last parameter: if (s.Length != 0) s = s.Remove(s.Length-1, 1); return s; }
//add's parameter to passed query string. Or updates if was there. string AddToQueryString(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!
> 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
ApplicationState, 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****************@tk2msftngp13.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***@DIESPAMMERSDIEtakempis.com> wrote in message news:ub**************@TK2MSFTNGP12.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.HttpRequest If Not IsNothing(System.Web.HttpContext.Current) then Request = System.Web.HttpContext.Current.Request End If
C#:
System.Web.HttpRequest Request if (System.Web.HttpContext.Current != null) Request = System.Web.HttpContext.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****************@TK2MSFTNGP09.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.QueryString) s += str + "=" + Request.QueryString[str] + "&";
//If not empty then cut off last parameter: if (s.Length != 0) s = s.Remove(s.Length-1, 1); return s; }
//add's parameter to passed query string. Or updates if was there. string AddToQueryString(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!
> 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?
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**************@TK2MSFTNGP12.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? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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: 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,...
|
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...
|
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...
|
by: connectrajesh |
last post by:
INTERVIEWINFO.NET
http://www.interviewinfo.net
FREE WEB SITE AND SERVICE FOR JOB SEEKERS /FRESH GRADUATES
NO ADVERTISEMENT
|
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...
|
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...
|
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...
|
by: Max2006 |
last post by:
Hi,
Which newsgroup should I post my questions related to Team Foundation Server
2008?
Thank you,
Max
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |