Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Problem with c#?


Message #1 by rune.ryen@s... on Tue, 23 Apr 2002 12:51:21
Hi 
I am having a problem with the code in the book: ASP.NET using c#.

In the onstart function I check on if the form element is blank and if it 
is the message should not be written.
My problem is that the first time I go to the page the first line comes 
out like this: You have selected 
But it should not be there at all as far as I understand.
Is this not a good way to check if there is nothing in a form element?

My code is like this:

<script runat="server" language="c#">
void Page_Load()
{
  if (Request.Form["list1"] != "")
  {
     Message.Text = "You have selected " + Request.Form["list1"];
  }
}
</script>
<html>
<head>
	<title>Drop Down List Example</title>
</head>
<body>
  <asp:label id="Message" runat="server"/>
  .
  .
  . 

From 
Rune Ryen
Norway
Message #2 by Elissa Setarehshenas <elissasetareh@y...> on Tue, 23 Apr 2002 05:06:00 -0700 (PDT)
The problem isn't C# its the book your using. The
Page_Load is wrong.  You must always ahve these 2
arguments in the function


private void Page_Load
(object sender, System.EventArgs e)

Elissa
		
--- rune.ryen@s... wrote:
> Hi 
> I am having a problem with the code in the book:
> ASP.NET using c#.
> 
> In the onstart function I check on if the form
> element is blank and if it 
> is the message should not be written.
> My problem is that the first time I go to the page
> the first line comes 
> out like this: You have selected 
> But it should not be there at all as far as I
> understand.
> Is this not a good way to check if there is nothing
> in a form element?
> 
> My code is like this:
> 
> <script runat="server" language="c#">
> void Page_Load()
> {
>   if (Request.Form["list1"] != "")
>   {
>      Message.Text = "You have selected " +
> Request.Form["list1"];
>   }
> }
> </script>
> <html>
> <head>
> 	<title>Drop Down List Example</title>
> </head>
> <body>
>   <asp:label id="Message" runat="server"/>
>   .
>   .
>   . 
> 
> From 
> Rune Ryen
> Norway


__________________________________________________
Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more
http://games.yahoo.com/
Message #3 by rune.ryen@s... on Wed, 24 Apr 2002 07:33:09
Hi, and thank you for the answer.

I tried this but I  still get the same result.

Rune

> The problem isn't C# its the book your using. The
Page_Load is wrong.  You must always ahve these 2
arguments in the function


private void Page_Load
(object sender, System.EventArgs e)

Elissa
		

  Return to Index