Day name of date object not working

N

.Net Sports

In my csharp code behind file, I'm trying to perform a redirect if the
date a user queries is a Wednesday:

string rqs = Request.QueryString["txtboarddate"];
string rqsday;
rqsday = (System.String.Format("{0:dddd}",rqs)) ;
if(rqsday == "Wednesday")
{
Response.Redirect("http://www.anothersite.com");
}

...but when the date (take today which is a Wednesday) is queried from
the prior page (everything on that page is formatted correctly because
it works when pointing to other functions of the script), I do not get
the redirect. When I comment out the "if" coding, the redirect does
work.

????
..Net Sports
 
B

Bob Barrows [MVP]

..Net Sports said:
In my csharp code behind file, I'm trying to perform a redirect if the
date a user queries is a Wednesday:

string rqs = Request.QueryString["txtboarddate"];
string rqsday;
rqsday = (System.String.Format("{0:dddd}",rqs)) ;
if(rqsday == "Wednesday")
{
Response.Redirect("http://www.anothersite.com");
}

..but when the date (take today which is a Wednesday) is queried from
the prior page (everything on that page is formatted correctly because
it works when pointing to other functions of the script), I do not get
the redirect. When I comment out the "if" coding, the redirect does
work.

????

Find out what rqsday contains. If using VS, then debug the project.
Otherwise, set the value to a label's Text property, or response.write the
value.

Bob Barrows
 
N

.Net Sports

It doesnt give me any errors when running from debug mode in VS. It's
just that 'rqsday' seems not to be picking up the day of the week name
I'm assigning it. How would I check a response.write if I'm doing this
in a code behind file. I try doing
if(rqsday == "Wednesday")
{
Response.Write("hello world");
}

but cannot see where (of if) it is getting printed.
 
B

Bob Barrows [MVP]

..Net Sports said:
It doesnt give me any errors when running from debug mode in VS.

Since you're using VS, just set a breakpoint and inspect the variable when
the process "breaks". Or set a Watch on the variable. Or use the Immediate
window to check its value.

Do you need some information on debugging?
It's
just that 'rqsday' seems not to be picking up the day of the week name
I'm assigning it. How would I check a response.write if I'm doing this
in a code behind file. I try doing
if(rqsday == "Wednesday")
{
Response.Write("hello world");
}

but cannot see where (of if) it is getting printed.

You're using Grid placement, right? The text is probably "underneath" one of
the controls on your page. Do a View Source to see it.

You should put a label on the page temporarily and set its Text property to
the value instead of writing it to Response.

Bob Barrows
 

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
474,434
Messages
2,571,685
Members
48,796
Latest member
Greg L.

Latest Threads

Top