|
 |
aspx_beginners thread: Request.Form["text1"]!=null using C#
Message #1 by gary@e... on Wed, 21 Aug 2002 10:13:31
|
|
Hi,
Here is a problem I posted before. The response I received was for VB but
this code is c#.
<script runat="server" language="C#">
void Page_Load() {
if(Request.Form["text1"] != null)
Message1.Text = "You have entered the following name: " +
Request.Form["text1"];
if(Request.Form["text2"] != null)
Message2.Text = "You have entered the following address: "
+
Request.Form["text2"];
if(Request.Form["text3"] != null)
Message3.Text = "You have entered the following
password: " +
Request.Form["text3"];
}
</script>
This is from Beginning ASP.Net Using C# p.118 textboxpage.aspx. It seems
to me that if you only enter data to one of the three text boxes then you
should only see an asp label print that single line. Instead I get this if
I only fill in the name in text1.
You have entered the following name: Gary Cook
You have entered the following address:
You have entered the following password:
The only time it doesn't print these lines is the first time it runs.
After that I get the design time text with no user input even if I enter
nothing? Thanks for any advice.
Message #2 by Simon Hargreaves <simon.hargreaves@r...> on Wed, 21 Aug 2002 10:44:21 +0100
|
|
gary,
In your if....then structures try replacing 'null' with "". This might sound
strange, but it might be worth a try.
PS. I do VB not C#, but its worth a try !
Sam
-----Original Message-----
From: gary@e... [mailto:gary@e...]
Sent: 21 August 2002 11:14
To: aspx_beginners
Subject: [aspx_beginners] Request.Form["text1"]!=null using C#
Hi,
Here is a problem I posted before. The response I received was for VB but
this code is c#.
<script runat="server" language="C#">
void Page_Load() {
if(Request.Form["text1"] != null)
Message1.Text = "You have entered the following name: " +
Request.Form["text1"];
if(Request.Form["text2"] != null)
Message2.Text = "You have entered the following address: "
+
Request.Form["text2"];
if(Request.Form["text3"] != null)
Message3.Text = "You have entered the following
password: " +
Request.Form["text3"];
}
</script>
This is from Beginning ASP.Net Using C# p.118 textboxpage.aspx. It seems
to me that if you only enter data to one of the three text boxes then you
should only see an asp label print that single line. Instead I get this if
I only fill in the name in text1.
You have entered the following name: Gary Cook
You have entered the following address:
You have entered the following password:
The only time it doesn't print these lines is the first time it runs.
After that I get the design time text with no user input even if I enter
nothing? Thanks for any advice.
---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=1861006195
Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=1861007418
These books look at how we can create data-centric ASP.NET
applications. Requiring some basic knowledge of ASP.NET,
Access and SQL the authors guide you through the process
of connecting and consuming information in a variety of
ways. They are packed full of excellent illustrative code
examples, demonstrating important fundamental principles.
Message #3 by Simon Hargreaves <simon.hargreaves@r...> on Wed, 21 Aug 2002 10:48:13 +0100
|
|
Hi Gary,
Another thought, you could set the visible property of the controls to false
at page_Load, then if the text property of your message(n) controls is other
than an empty string, turn the visible property on.
Sam
-----Original Message-----
From: gary@e... [mailto:gary@e...]
Sent: 21 August 2002 11:14
To: aspx_beginners
Subject: [aspx_beginners] Request.Form["text1"]!=null using C#
Hi,
Here is a problem I posted before. The response I received was for VB but
this code is c#.
<script runat="server" language="C#">
void Page_Load() {
if(Request.Form["text1"] != null)
Message1.Text = "You have entered the following name: " +
Request.Form["text1"];
if(Request.Form["text2"] != null)
Message2.Text = "You have entered the following address: "
+
Request.Form["text2"];
if(Request.Form["text3"] != null)
Message3.Text = "You have entered the following
password: " +
Request.Form["text3"];
}
</script>
This is from Beginning ASP.Net Using C# p.118 textboxpage.aspx. It seems
to me that if you only enter data to one of the three text boxes then you
should only see an asp label print that single line. Instead I get this if
I only fill in the name in text1.
You have entered the following name: Gary Cook
You have entered the following address:
You have entered the following password:
The only time it doesn't print these lines is the first time it runs.
After that I get the design time text with no user input even if I enter
nothing? Thanks for any advice.
---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=1861006195
Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=1861007418
These books look at how we can create data-centric ASP.NET
applications. Requiring some basic knowledge of ASP.NET,
Access and SQL the authors guide you through the process
of connecting and consuming information in a variety of
ways. They are packed full of excellent illustrative code
examples, demonstrating important fundamental principles.
Message #4 by gary@e... on Tue, 27 Aug 2002 04:05:09
|
|
Hi Sam,
This is the same answer you gave before. It gives even worse results.
Thanks anyway.
Gary
Message #5 by gary@e... on Wed, 28 Aug 2002 03:50:33
|
|
Hi Sam,
if(Request.Form["text1"] != null && Request.Form["text1"] != "")
This seems to work as well as anything will. Once you do enter something
into a text box asp on the server seems to remember it and sends it as a
message even if the specific text box is now empty.
The null part catches it the first time it runs and the "" part catches
it when you press the submitt button. Using submit seems to send an empty
system string as I found out using - Request.Form["text2"].GetType()
Gary
|
|
 |