|
 |
aspx_beginners thread: aspx:textbox control
Message #1 by gary@e... on Fri, 2 Aug 2002 03:58:52
|
|
Hi,
I'm reviewing try it out <aspx:textbox> control in Ch.3 p.118
of "Beginninbg ASP.NET".
If I run it as written in the book with this if statement:
if(Request.Form["text1"] != "")
{
Message1.Text = "You have entered the following name: " +
Request.Form["text1"];
}
the result is that the first time the page is accessed the string portion
of Message1 as well as for the other two messages are writen in the
response.
So I changed it to if(Request.Form["test1"] != null) . This worked
better. The first iteration showed no message in the response, just the 3
text boxes. It works fine if I enter data to all the text boxes.
I still have a problem though as if I enter data into only one of the
three text boxes the response writes the appropriate message and the input
data, but it also writes the not required message, for example the "You
have entered the following address: ", but with no data.
I seems to me that the following code which I am using should only
write a message for a textbox if there has been data entered into that
control specifically, not the others.
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"];
}
}
Thank you for any advice.
Gary
gary@e...
Message #2 by Simon Hargreaves <Simon.Hargreaves@c...> on Fri, 2 Aug 2002 09:10:33 +0100
|
|
Hi There Gary,
For inequality have you considered using
If text1.Text <> "" Then
......Your conditional code.......
End If
Regards
Sam
-----Original Message-----
From: gary@e... [mailto:gary@e...]
Sent: 02 August 2002 04:59
To: aspx_beginners
Subject: [aspx_beginners] aspx:textbox control
Hi,
I'm reviewing try it out <aspx:textbox> control in Ch.3 p.118
of "Beginninbg ASP.NET".
If I run it as written in the book with this if statement:
if(Request.Form["text1"] != "")
{
Message1.Text = "You have entered the following name: " +
Request.Form["text1"];
}
the result is that the first time the page is accessed the string portion
of Message1 as well as for the other two messages are writen in the
response.
So I changed it to if(Request.Form["test1"] != null) . This worked
better. The first iteration showed no message in the response, just the 3
text boxes. It works fine if I enter data to all the text boxes.
I still have a problem though as if I enter data into only one of the
three text boxes the response writes the appropriate message and the input
data, but it also writes the not required message, for example the "You
have entered the following address: ", but with no data.
I seems to me that the following code which I am using should only
write a message for a textbox if there has been data entered into that
control specifically, not the others.
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"];
}
}
Thank you for any advice.
Gary
gary@e...
|
|
 |