Setting a Default Value

B

Brad Baker

I have an asp.net/csharp application that requires a particular variable to
work properly. This variable is usually passed via a query string in the URL
when the application is first run but under certain circumstances the query
string may not contain the variable. So I need some way of establishing a
default value if one isn't set.

Is there some way I can set a query string on page_load OR is there some way
I can use a global variable which is accessible throughout my application
instead? In pseudo code something like:

public void Page_Load(object sender, EventArgs e)
{
if (querystring == null)
{
global myvariable = "somevalue";
} else {
global myvariable = querystring;
}
}

protected void dostuff(object sender, EventArgs e)
{
if (myvariable == "foo")
{
// do stuff
}
}

Hopefully this makes sense - for clarity sake I have tried to simplify my
situation as much as possible.

Thanks
Brad
 
S

sloan

Put this in a class somewhere.



public static string SafeSessionGet(Page pageObj, string requestKey,
string defaultValue)
{
if (pageObj.Request[requestKey] == null)
{
return defaultValue;
}
else
{
return pageObj.Request[requestKey].ToString ();
}
}




public static string SafeSessionGet(Page pageObj, string requestKey)
{
return SafeSessionGet ( pageObj , requestKey , string.Empty ) ;
}





You could write a generics version of this in 2.0 if you wanted, but that
might be overkill.


private string m_empUUID = string.Empty;
public void Page_Load(object sender, EventArgs e)
{


m_empUUID = SafeSessionGet ( Page , "empkey" ) ;
//or

m_empUUID = SafeSessionGet ( Page , "empkey" ,
"00000-00000-000000000-000000000" ) ;


 
B

Brad Baker

I'm a bit of an asp.net/csharp newbie so please bear with me. If I
understand you correctly, I would call: SafeSessionGet(myvariable) to get
the query string value (or assign a default value) each time I needed to
reference myvariable?



Assuming that's correct, I'm not sure if that's the best solution as I am
going to assign the default value through a database query. So for instance
I might have the following (again in pseudo code):



if myvariable == null {

run the following SQL query: select * from table where x = 1

myvariable = first result of sql query

}



So for instance if I needed to call myvariable from four different sections
of my code I would have to run the sql query four times? Isn't that fairly
inefficient performance wise? I was thinking of trying to set myvariable
once using one SQL query then reuse it throughout my application. I was
hoping to do that through some sort of global variable (I'm not sure csharp
has anything like that or not though).



Maybe I am misunderstanding you or maybe there is some other approach I'm
overlooking. Any additional guidance you could provide would be sincerely
appreciated. :)



Thanks Again,

Brad



sloan said:
Put this in a class somewhere.



public static string SafeSessionGet(Page pageObj, string requestKey,
string defaultValue)
{
if (pageObj.Request[requestKey] == null)
{
return defaultValue;
}
else
{
return pageObj.Request[requestKey].ToString ();
}
}




public static string SafeSessionGet(Page pageObj, string requestKey)
{
return SafeSessionGet ( pageObj , requestKey , string.Empty ) ;
}





You could write a generics version of this in 2.0 if you wanted, but that
might be overkill.


private string m_empUUID = string.Empty;
public void Page_Load(object sender, EventArgs e)
{


m_empUUID = SafeSessionGet ( Page , "empkey" ) ;
//or

m_empUUID = SafeSessionGet ( Page , "empkey" ,
"00000-00000-000000000-000000000" ) ;









Brad Baker said:
I have an asp.net/csharp application that requires a particular variable to
work properly. This variable is usually passed via a query string in the URL
when the application is first run but under certain circumstances the query
string may not contain the variable. So I need some way of establishing a
default value if one isn't set.

Is there some way I can set a query string on page_load OR is there some way
I can use a global variable which is accessible throughout my application
instead? In pseudo code something like:

public void Page_Load(object sender, EventArgs e)
{
if (querystring == null)
{
global myvariable = "somevalue";
} else {
global myvariable = querystring;
}
}

protected void dostuff(object sender, EventArgs e)
{
if (myvariable == "foo")
{
// do stuff
}
}

Hopefully this makes sense - for clarity sake I have tried to simplify my
situation as much as possible.

Thanks
Brad
 
G

Guest

if your default value needs to come out of the database but it does not change,
the make the Sql call from within Application_Start in Global.asax. You can
then either store it in Application state or in a static field in the Global
class.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




Brad Baker said:
I'm a bit of an asp.net/csharp newbie so please bear with me. If I
understand you correctly, I would call: SafeSessionGet(myvariable) to get
the query string value (or assign a default value) each time I needed to
reference myvariable?



Assuming that's correct, I'm not sure if that's the best solution as I am
going to assign the default value through a database query. So for instance
I might have the following (again in pseudo code):



if myvariable == null {

run the following SQL query: select * from table where x = 1

myvariable = first result of sql query

}



So for instance if I needed to call myvariable from four different sections
of my code I would have to run the sql query four times? Isn't that fairly
inefficient performance wise? I was thinking of trying to set myvariable
once using one SQL query then reuse it throughout my application. I was
hoping to do that through some sort of global variable (I'm not sure csharp
has anything like that or not though).



Maybe I am misunderstanding you or maybe there is some other approach I'm
overlooking. Any additional guidance you could provide would be sincerely
appreciated. :)



Thanks Again,

Brad



sloan said:
Put this in a class somewhere.



public static string SafeSessionGet(Page pageObj, string requestKey,
string defaultValue)
{
if (pageObj.Request[requestKey] == null)
{
return defaultValue;
}
else
{
return pageObj.Request[requestKey].ToString ();
}
}




public static string SafeSessionGet(Page pageObj, string requestKey)
{
return SafeSessionGet ( pageObj , requestKey , string.Empty ) ;
}





You could write a generics version of this in 2.0 if you wanted, but that
might be overkill.


private string m_empUUID = string.Empty;
public void Page_Load(object sender, EventArgs e)
{


m_empUUID = SafeSessionGet ( Page , "empkey" ) ;
//or

m_empUUID = SafeSessionGet ( Page , "empkey" ,
"00000-00000-000000000-000000000" ) ;









Brad Baker said:
I have an asp.net/csharp application that requires a particular variable to
work properly. This variable is usually passed via a query string in the URL
when the application is first run but under certain circumstances the query
string may not contain the variable. So I need some way of establishing a
default value if one isn't set.

Is there some way I can set a query string on page_load OR is there some way
I can use a global variable which is accessible throughout my application
instead? In pseudo code something like:

public void Page_Load(object sender, EventArgs e)
{
if (querystring == null)
{
global myvariable = "somevalue";
} else {
global myvariable = querystring;
}
}

protected void dostuff(object sender, EventArgs e)
{
if (myvariable == "foo")
{
// do stuff
}
}

Hopefully this makes sense - for clarity sake I have tried to simplify my
situation as much as possible.

Thanks
Brad
 
B

Brad Baker

Hmm what do you mean by "if your default value needs to come out of the
database but it does not change"?

Basically my app could be called using the following URL:
http://www.mydomain.com/myapp.aspx?id=1234

Or it could be called using this URL:
http://www.mydomain.com/myapp.aspx?id=1234&myvariable=AB123NDOWQ

If the former is used (without a myvariable in the URL) then I want to
default myvariable to a certain value. But the value I want to default to
may change depending on the ID in the URL. In other words I could also have
the following URLs:

http://www.mydomain.com/myapp.aspx?id=1235
http://www.mydomain.com/myapp.aspx?id=1236
http://www.mydomain.com/myapp.aspx?id=1237

Thanks
Brad


Peter Bromberg said:
if your default value needs to come out of the database but it does not
change,
the make the Sql call from within Application_Start in Global.asax. You
can
then either store it in Application state or in a static field in the
Global
class.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




Brad Baker said:
I'm a bit of an asp.net/csharp newbie so please bear with me. If I
understand you correctly, I would call: SafeSessionGet(myvariable) to get
the query string value (or assign a default value) each time I needed to
reference myvariable?



Assuming that's correct, I'm not sure if that's the best solution as I am
going to assign the default value through a database query. So for
instance
I might have the following (again in pseudo code):



if myvariable == null {

run the following SQL query: select * from table where x = 1

myvariable = first result of sql query

}



So for instance if I needed to call myvariable from four different
sections
of my code I would have to run the sql query four times? Isn't that
fairly
inefficient performance wise? I was thinking of trying to set myvariable
once using one SQL query then reuse it throughout my application. I was
hoping to do that through some sort of global variable (I'm not sure
csharp
has anything like that or not though).



Maybe I am misunderstanding you or maybe there is some other approach I'm
overlooking. Any additional guidance you could provide would be sincerely
appreciated. :)



Thanks Again,

Brad



sloan said:
Put this in a class somewhere.



public static string SafeSessionGet(Page pageObj, string requestKey,
string defaultValue)
{
if (pageObj.Request[requestKey] == null)
{
return defaultValue;
}
else
{
return pageObj.Request[requestKey].ToString ();
}
}




public static string SafeSessionGet(Page pageObj, string requestKey)
{
return SafeSessionGet ( pageObj , requestKey , string.Empty ) ;
}





You could write a generics version of this in 2.0 if you wanted, but
that
might be overkill.


private string m_empUUID = string.Empty;

public void Page_Load(object sender, EventArgs e)
{


m_empUUID = SafeSessionGet ( Page , "empkey" ) ;
//or

m_empUUID = SafeSessionGet ( Page , "empkey" ,
"00000-00000-000000000-000000000" ) ;



}







I have an asp.net/csharp application that requires a particular
variable
to
work properly. This variable is usually passed via a query string in
the
URL
when the application is first run but under certain circumstances the
query
string may not contain the variable. So I need some way of
establishing a
default value if one isn't set.

Is there some way I can set a query string on page_load OR is there
some
way
I can use a global variable which is accessible throughout my
application
instead? In pseudo code something like:

public void Page_Load(object sender, EventArgs e)
{
if (querystring == null)
{
global myvariable = "somevalue";
} else {
global myvariable = querystring;
}
}

protected void dostuff(object sender, EventArgs e)
{
if (myvariable == "foo")
{
// do stuff
}
}

Hopefully this makes sense - for clarity sake I have tried to simplify
my
situation as much as possible.

Thanks
Brad
 
S

Steven Cheng[MSFT]

Hi Brad,

I agree with sloan that since QueryString variable doesn't support supply
default value, it is reasonable to use a class property or method to
wrapper the querystring value. e.g.

=====================
class ....
{
public String GetQueryStringValue(string name)
{
if(HttpContext.Current.Request.Querystring[name] != null)
{
//return it
}else
{
//return default value
}
}

}
======================

such as class can be reused in multiple pages. Also, if your concern is
that the default value will be polled out from backend database and you do
not want to make multiple database query whenever you need to return the
default value, I think you can add a further property/method to cache the
default value. That property/method will always return the default value
from a private variable or from the ApplicationState collection that can
be initialized at application's startup time or the first time the default
value is requested. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

Brad Baker

I'm hesitant to use classes just because I'm unfamilarity with them :) That
seems to be the consensus on how to best acheive this but I sitll wondering
if there isn't a simplier way. My web "app" is basically one aspx page and
two user controls not incredibly complex.

Anyway I have added the following to my default.aspx page:
<%@ import namespace="MyNamespace" %>

Then I have added a class file (under app_code/class.cs) with the following:
namespace MyNamespace
{
public class MyClass
{
public String GetQueryStringValue(string name)
{
if (HttpContext.Current.Request.QueryString[name] != null)
{
//return it
return HttpContext.Current.Request.QueryString[name].ToString();
}
else
{
//return default value (hard coded for now)
return "e62bbc7d623f445658e131cba90e83982";
}
}
}
}

From default.aspx I have the following call:
<%# Foundation.GetQueryStringValue(querystringid); %>

Basically I am just trying to start out very simple and confirm that I can
get the querystringid and print it out. However when I run this I get the
following error: CS1026: ) expected.

I assume I'm doing something wrong but I'm a little lost as to where. :) I'm
going to do a bit more reading on classes but if you have any suggestions
I'd welcome feedback.

Thanks
Brad



Steven Cheng said:
Hi Brad,

I agree with sloan that since QueryString variable doesn't support supply
default value, it is reasonable to use a class property or method to
wrapper the querystring value. e.g.

=====================
class ....
{
public String GetQueryStringValue(string name)
{
if(HttpContext.Current.Request.Querystring[name] != null)
{
//return it
}else
{
//return default value
}
}

}
======================

such as class can be reused in multiple pages. Also, if your concern is
that the default value will be polled out from backend database and you do
not want to make multiple database query whenever you need to return the
default value, I think you can add a further property/method to cache the
default value. That property/method will always return the default value
from a private variable or from the ApplicationState collection that can
be initialized at application's startup time or the first time the default
value is requested. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no
rights.
 
S

sloan

Sorry dude. We've made it as simple as you can.

If you're in 1.1, then create a subfolder called "App_Code" in your web
project.
Under App_Code, create a class called
"QueryStringHelper" (.cs) or something like that.

Add the method I made to the class (or Steven's)

Call the method.

Eventually you're going to have to add some kind of logic class to your
application. So you might as well learn with this simple issue.




Brad Baker said:
I'm hesitant to use classes just because I'm unfamilarity with them :) That
seems to be the consensus on how to best acheive this but I sitll wondering
if there isn't a simplier way. My web "app" is basically one aspx page and
two user controls not incredibly complex.

Anyway I have added the following to my default.aspx page:
<%@ import namespace="MyNamespace" %>

Then I have added a class file (under app_code/class.cs) with the following:
namespace MyNamespace
{
public class MyClass
{
public String GetQueryStringValue(string name)
{
if (HttpContext.Current.Request.QueryString[name] != null)
{
//return it
return HttpContext.Current.Request.QueryString[name].ToString();
}
else
{
//return default value (hard coded for now)
return "e62bbc7d623f445658e131cba90e83982";
}
}
}
}

From default.aspx I have the following call:
<%# Foundation.GetQueryStringValue(querystringid); %>

Basically I am just trying to start out very simple and confirm that I can
get the querystringid and print it out. However when I run this I get the
following error: CS1026: ) expected.

I assume I'm doing something wrong but I'm a little lost as to where. :) I'm
going to do a bit more reading on classes but if you have any suggestions
I'd welcome feedback.

Thanks
Brad



Steven Cheng said:
Hi Brad,

I agree with sloan that since QueryString variable doesn't support supply
default value, it is reasonable to use a class property or method to
wrapper the querystring value. e.g.

=====================
class ....
{
public String GetQueryStringValue(string name)
{
if(HttpContext.Current.Request.Querystring[name] != null)
{
//return it
}else
{
//return default value
}
}

}
======================

such as class can be reused in multiple pages. Also, if your concern is
that the default value will be polled out from backend database and you do
not want to make multiple database query whenever you need to return the
default value, I think you can add a further property/method to cache the
default value. That property/method will always return the default value
from a private variable or from the ApplicationState collection that can
be initialized at application's startup time or the first time the default
value is requested. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no
rights.
 
B

Brad Baker

I am using 2.0 and I have a subfolder called App_Code as mentioned in my
previous post. I have a class file (its just called class.cs). I've defined
a namespace (mynamespace) and a class (myclass) and so forth. I guess my
confusion is weather I've implemented the class wrong, called the method
wrong or if I've screwed up something else entirely different. :)

BTW - I am using "C# Web development with ASP.NET" as a resource along with
Google and the asp.net website. Does anyone have any other recommendations
for learning the basics and/or reference material. Particularly with
regards to class files (but in general would be helpful as well)

Thanks,
Brad


sloan said:
Sorry dude. We've made it as simple as you can.

If you're in 1.1, then create a subfolder called "App_Code" in your web
project.
Under App_Code, create a class called
"QueryStringHelper" (.cs) or something like that.

Add the method I made to the class (or Steven's)

Call the method.

Eventually you're going to have to add some kind of logic class to your
application. So you might as well learn with this simple issue.




Brad Baker said:
I'm hesitant to use classes just because I'm unfamilarity with them :) That
seems to be the consensus on how to best acheive this but I sitll wondering
if there isn't a simplier way. My web "app" is basically one aspx page
and
two user controls not incredibly complex.

Anyway I have added the following to my default.aspx page:
<%@ import namespace="MyNamespace" %>

Then I have added a class file (under app_code/class.cs) with the following:
namespace MyNamespace
{
public class MyClass
{
public String GetQueryStringValue(string name)
{
if (HttpContext.Current.Request.QueryString[name] != null)
{
//return it
return HttpContext.Current.Request.QueryString[name].ToString();
}
else
{
//return default value (hard coded for now)
return "e62bbc7d623f445658e131cba90e83982";
}
}
}
}

From default.aspx I have the following call:
<%# Foundation.GetQueryStringValue(querystringid); %>

Basically I am just trying to start out very simple and confirm that I
can
get the querystringid and print it out. However when I run this I get the
following error: CS1026: ) expected.

I assume I'm doing something wrong but I'm a little lost as to where. :) I'm
going to do a bit more reading on classes but if you have any suggestions
I'd welcome feedback.

Thanks
Brad



Steven Cheng said:
Hi Brad,

I agree with sloan that since QueryString variable doesn't support supply
default value, it is reasonable to use a class property or method to
wrapper the querystring value. e.g.

=====================
class ....
{
public String GetQueryStringValue(string name)
{
if(HttpContext.Current.Request.Querystring[name] != null)
{
//return it
}else
{
//return default value
}
}

}
======================

such as class can be reused in multiple pages. Also, if your concern
is
that the default value will be polled out from backend database and you do
not want to make multiple database query whenever you need to return
the
default value, I think you can add a further property/method to cache the
default value. That property/method will always return the default
value
from a private variable or from the ApplicationState collection that can
be initialized at application's startup time or the first time the default
value is requested. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no
rights.
 
S

sloan

Make the function static.

Then call it via

string x = MyNamespace.MyClass.GetQueryStringValue( //params here// ) ;

Every object in your application has a fully qualfied name. You sometimes
have to use the full name.


(in the future you can also use a "using MyNamespace" at the top of your
code.

You need to google "C# namespaces" and read some basic info on it.






Brad Baker said:
I am using 2.0 and I have a subfolder called App_Code as mentioned in my
previous post. I have a class file (its just called class.cs). I've defined
a namespace (mynamespace) and a class (myclass) and so forth. I guess my
confusion is weather I've implemented the class wrong, called the method
wrong or if I've screwed up something else entirely different. :)

BTW - I am using "C# Web development with ASP.NET" as a resource along with
Google and the asp.net website. Does anyone have any other recommendations
for learning the basics and/or reference material. Particularly with
regards to class files (but in general would be helpful as well)

Thanks,
Brad


sloan said:
Sorry dude. We've made it as simple as you can.

If you're in 1.1, then create a subfolder called "App_Code" in your web
project.
Under App_Code, create a class called
"QueryStringHelper" (.cs) or something like that.

Add the method I made to the class (or Steven's)

Call the method.

Eventually you're going to have to add some kind of logic class to your
application. So you might as well learn with this simple issue.




Brad Baker said:
I'm hesitant to use classes just because I'm unfamilarity with them :) That
seems to be the consensus on how to best acheive this but I sitll wondering
if there isn't a simplier way. My web "app" is basically one aspx page
and
two user controls not incredibly complex.

Anyway I have added the following to my default.aspx page:
<%@ import namespace="MyNamespace" %>

Then I have added a class file (under app_code/class.cs) with the following:
namespace MyNamespace
{
public class MyClass
{
public String GetQueryStringValue(string name)
{
if (HttpContext.Current.Request.QueryString[name] != null)
{
//return it
return HttpContext.Current.Request.QueryString[name].ToString();
}
else
{
//return default value (hard coded for now)
return "e62bbc7d623f445658e131cba90e83982";
}
}
}
}

From default.aspx I have the following call:
<%# Foundation.GetQueryStringValue(querystringid); %>

Basically I am just trying to start out very simple and confirm that I
can
get the querystringid and print it out. However when I run this I get the
following error: CS1026: ) expected.

I assume I'm doing something wrong but I'm a little lost as to where.
:)
I'm
going to do a bit more reading on classes but if you have any suggestions
I'd welcome feedback.

Thanks
Brad



Hi Brad,

I agree with sloan that since QueryString variable doesn't support supply
default value, it is reasonable to use a class property or method to
wrapper the querystring value. e.g.

=====================
class ....
{
public String GetQueryStringValue(string name)
{
if(HttpContext.Current.Request.Querystring[name] != null)
{
//return it
}else
{
//return default value
}
}

}
======================

such as class can be reused in multiple pages. Also, if your concern
is
that the default value will be polled out from backend database and
you
do
not want to make multiple database query whenever you need to return
the
default value, I think you can add a further property/method to cache the
default value. That property/method will always return the default
value
from a private variable or from the ApplicationState collection that can
be initialized at application's startup time or the first time the default
value is requested. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no
rights.
 
S

Steven Cheng[MSFT]

Hi Brad,

As for the code you posted:

===============
Then I have added a class file (under app_code/class.cs) with the following:
namespace MyNamespace
{
public class MyClass
{
public String GetQueryStringValue(string name)
{
if (HttpContext.Current.Request.QueryString[name] != null)
{
//return it
return HttpContext.Current.Request.QueryString[name].ToString();
}
else
{
//return default value (hard coded for now)
return "e62bbc7d623f445658e131cba90e83982";
}
}
}
}

From default.aspx I have the following call:
<%# Foundation.GetQueryStringValue(querystringid); %>
=============

what is "Foundation"? I haven't seen the definitio of it, you can declare
the method "GetQueryStringValue" as static funciton so as to use it through
"Namespace.ClassName.MethodName" as sloan has suggested.

Also, in databinding expression(<%# %>) , you do not need to add ";" ,
this will also cause error.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top