473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

"if" problem. Still. Value is ok.

Hi,

i have this code line in a script in my ASP.net / VB web site:

dim msgNewsletterAction

msgNewsletterAction = Request.Form("newsletterAction")

if msgNewsletterAction = "go" Then
Code1
Else
Code2
End If

Code2 runs everytime even when msgNewsletterAction = "go". Code1 never runs.

I sent the value of msgNewsletterAction to an email address using
AspNetEmail.
I readed my email and the value of the variable was correct and equal to
"go".

So why doesn't Code1 runs?

Thanks,
Miguel

Nov 20 '05 #1
4 873
"Miguel Dias Moura" <in************@27lamps.com> schrieb

Please don't open a new thread for the the issue.
i have this code line in a script in my ASP.net / VB web site:

dim msgNewsletterAction
I hope in your real application you have Option Strict On.
msgNewsletterAction = Request.Form("newsletterAction")
Try this here:

msgbox msgNewsletterAction.gettype.fullname
msgbox msgNewsletterAction.tostring.length

What is displayed?
if msgNewsletterAction = "go" Then
Code1
Else
Code2
End If

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
What if you declared msgNewsletterAction as
Dim msgNewsletterAction as String?

And by using CType(Request.Form("newsletterAction"), GetType(System.String))

Serge

"Miguel Dias Moura" <in************@27lamps.com> wrote in message
news:uB*************@tk2msftngp13.phx.gbl...
Hi,

i have this code line in a script in my ASP.net / VB web site:

dim msgNewsletterAction

msgNewsletterAction = Request.Form("newsletterAction")

if msgNewsletterAction = "go" Then
Code1
Else
Code2
End If

Code2 runs everytime even when msgNewsletterAction = "go". Code1 never runs.
I sent the value of msgNewsletterAction to an email address using
AspNetEmail.
I readed my email and the value of the variable was correct and equal to
"go".

So why doesn't Code1 runs?

Thanks,
Miguel

Nov 20 '05 #3
I would check a few more things as well.

First of all, using Request.Form only grabs variables that are POSTed, not
through the QueryString, since I don't know his query string, I thought I
would just bring that up.

Second, is Option Compare Text on? (this is why I don't use strings in web
queries). Go != GO != go

Third, Listen to Armin about the option strict on, using a straight out Dim
reminds me of old asp 2.0 days... It's extra work to go through all those
conversions... That, and its just bad practice.
"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de...
"Miguel Dias Moura" <in************@27lamps.com> schrieb

Please don't open a new thread for the the issue.
i have this code line in a script in my ASP.net / VB web site:

dim msgNewsletterAction


I hope in your real application you have Option Strict On.
msgNewsletterAction = Request.Form("newsletterAction")


Try this here:

msgbox msgNewsletterAction.gettype.fullname
msgbox msgNewsletterAction.tostring.length

What is displayed?
if msgNewsletterAction = "go" Then
Code1
Else
Code2
End If

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4
* "Miguel Dias Moura" <in************@27lamps.com> scripsit:
i have this code line in a script in my ASP.net / VB web site:

dim msgNewsletterAction

msgNewsletterAction = Request.Form("newsletterAction")

if msgNewsletterAction = "go" Then
Code1
Else
Code2
End If

Code2 runs everytime even when msgNewsletterAction = "go". Code1 never runs.

I sent the value of msgNewsletterAction to an email address using
AspNetEmail.
I readed my email and the value of the variable was correct and equal to
"go".

So why doesn't Code1 runs?


Isn't there any other way to output the value and check it?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5

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

Similar topics

3
by: Chris Tilley - HPC:Factor | last post by:
Hi, I'm utterly confounded by this one. There must be some sort of rule that I don't know of. I'd consider myself a Newbie+1, so be gentle. I have a database connection (working A-Ok) and a...
40
by: Steve Juranich | last post by:
I know that this topic has the potential for blowing up in my face, but I can't help asking. I've been using Python since 1.5.1, so I'm not what you'd call a "n00b". I dutifully evangelize on the...
35
by: David Cleaver | last post by:
Hello all, I was wondering if there were some sort of limitations on the "if" statement? I'm writing a program which needs to check a bunch of conditions all at the same time (basically). And...
3
by: Mark Sullivan | last post by:
When I trace through a csharp program I came to a situation where a certain values has an "undefined value" as shown in the debugger DbgClr. I want to check this but the following statements did...
2
by: Miguel Dias Moura | last post by:
Hi, i have this code line in a script in my ASP.net / VB web site: dim msgNewsletterAction msgNewsletterAction = Request.Form("newsletterAction") if msgNewsletterAction = "go" Then Code1
4
by: cwoll | last post by:
I am runing this function to toggle buttens to display an "X" when they is selected, the butten is linked to a yes/no field. This function works good, the problem I am having is that when I make a...
0
by: eyalhz | last post by:
I have this code at button click: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If ListBox1.SelectedIndex() Then Dim lines As...
13
by: Jim in Arizona | last post by:
I made a page with a gridview that has rows show a different color if a number in a column is greater than or equal to 45. I also did this conditional formatting for the column next to it. Here's...
37
by: jht5945 | last post by:
For example I wrote a function: function Func() { // do something } we can call it like: var obj = new Func(); // call it as a constructor or var result = Func(); // call it as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.