Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Problems with if statement


Message #1 by "Trond Ulseth" <trond@i...> on Wed, 13 Mar 2002 08:59:11
Hi all,



I just started out with the "Begining ASP.NET using C#". On page 108 the 

code on top is like this:



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

  void Page_Load()

  {

    if (Request.Form["list1"] != "") 

    {

      message.Text = "You have selected " + Request.Form["list1"];

    }

  }

</script>



and in the body:



<asp:label id="message" runat="server"/>



The problem is that the first time I run the page (before filling in the 

form) it still writes: "You have selected".



I thought maybe I did something wrong, but the same happened with the code 

I downloaded from the wrox.com page.



In advance thanx a lot for any help on this
Message #2 by "paulcr" <paulcr@c...> on Wed, 13 Mar 2002 12:28:26 -0000
Yeah there is a  problem with that code, dont worry its not your error I had

the same problem

If you change it to............

if(Request.Form["list1"]!= null)

it will work



>

> Hi all,

>

> I just started out with the "Begining ASP.NET using C#". On page 108 the

> code on top is like this:

>

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

>   void Page_Load()

>   {

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

>     {

>       message.Text = "You have selected " + Request.Form["list1"];

>     }

>   }

> </script>

>

> and in the body:

>

> <asp:label id="message" runat="server"/>

>

> The problem is that the first time I run the page (before filling in the

> form) it still writes: "You have selected".

>

> I thought maybe I did something wrong, but the same happened with the code

> I downloaded from the wrox.com page.

>

> In advance thanx a lot for any help on this

>

>





Message #3 by "Mckinnon, David J" <david.mckinnon@e...> on Wed, 13 Mar 2002 07:01:13 -0500
Trond,



Insert something like the following line before your ASPx Processing code:



	If Request.Querystring("isSubmitted") = "yes" Then

		|

		code, code, code

		|

	End If



This assumes your using method="get" in your Form.  For method="post" use:



	Request.Form("isSubmitted")







Insert something like this line just before your SUBMIT button in your HTML

Form:



	<input type="hidden" name="isSubmitted" value="yes">







HTH,



David







-----Original Message-----

From: Trond Ulseth [mailto:trond@i...]

Sent: Wednesday, March 13, 2002 3:59 AM

To: aspx_beginners

Subject: [aspx_beginners] Problems with if statement





Hi all,



I just started out with the "Begining ASP.NET using C#". On page 108 the 

code on top is like this:



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

  void Page_Load()

  {

    if (Request.Form["list1"] != "") 

    {

      message.Text = "You have selected " + Request.Form["list1"];

    }

  }

</script>



and in the body:



<asp:label id="message" runat="server"/>



The problem is that the first time I run the page (before filling in the 

form) it still writes: "You have selected".



I thought maybe I did something wrong, but the same happened with the code 

I downloaded from the wrox.com page.



In advance thanx a lot for any help on this




$subst('Email.Unsub').


  Return to Index