Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: confusion about if statement and text box value


Message #1 by gary@e... on Thu, 7 Mar 2002 03:52:16
Hi,

  I am doing radiopage.aspx from 'Beginning ASP.NET using c#'. The results 

of the following code are confusing me.

  <script runat="server" language="c#">

	void Page_Load() {

		if(Request.Form["radio1"] != "") {

			Message.Text = "You have selected the following: " 

+ Request.Form["radio1"];

		}

	}

</script>

  If the text box, or in this case radio button 'radio1', are left blank 

or unchecked the first part of the message is still displayed. It seems to 

me that if(Request.Form["radio1"] != "") will return 0 if the radio 

buttons are all unchecked and then nothing is sent with the request. What 

is the point of the if statement if it exicutes even if radio1 does == ""?



Thank you

Message #2 by "Trond Ulseth" <trond@i...> on Wed, 13 Mar 2002 13:02:47
I had a similar question which was answered by paulcr. Check my thread 

further up.



> Hi,

>   I am doing radiopage.aspx from 'Beginning ASP.NET using c#'. The 

results 

> of the following code are confusing me.

>   <script runat="server" language="c#">

> 	void Page_Load() {

> 		if(Request.Form["radio1"] != "") {

> 			Message.Text = "You have selected the following: " 

> + Request.Form["radio1"];

> 		}

> 	}

> </script>

>   If the text box, or in this case radio button 'radio1', are left blank 

> or unchecked the first part of the message is still displayed. It seems 

to 

> me that if(Request.Form["radio1"] != "") will return 0 if the radio 

> buttons are all unchecked and then nothing is sent with the request. 

What 

> is the point of the if statement if it exicutes even if radio1 does 

== ""?

> 

> Thank you


  Return to Index