473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Response.Write() ??

Hi,

On a webform do I have a label, a textBox (txtName) and a submit-button (all
asp server controls) :

Upon pressing the button do I write the entered name in the html-output
stream (at server site) :
private void idSubmit_Click(object sender, System.EventArgs e)
{
string str = "Thanks for filling out our survey " + txtName.Text +
"<br>";
Response.Write(str);
}

That works when I execute this in a brower but I see all the controls
displayed as well.

How can I only display the entered name as a reponse ?

thnx
Chris
Nov 18 '05 #1
7 2047
On Thu, 09 Sep 2004 11:28:50 GMT, Chris wrote:
Hi,

On a webform do I have a label, a textBox (txtName) and a submit-button (all
asp server controls) :

Upon pressing the button do I write the entered name in the html-output
stream (at server site) :
private void idSubmit_Click(object sender, System.EventArgs e)
{
string str = "Thanks for filling out our survey " + txtName.Text +
"<br>";
Response.Write(str);
}

That works when I execute this in a brower but I see all the controls
displayed as well.

How can I only display the entered name as a reponse ?

thnx
Chris


First of all: buy an ASP.NET book to read in on the fundamentals.

If you want to hide controls, use:
idSubmit.Visible=false;
txtName.Visible=false;

You should use a label control to output your message to the user. The
message may look ok, but the Click event is handled before Page.Render()
causing something like:

Thanks for filling out our survey Doe<BR>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
....
</HTML>

Which is less than perfect.

/Hugo
Nov 18 '05 #2
Don't write to response (although you can if you wish). Rather prepare all
you want to render in design time and manipulate Visible property.

Eliyahu

"Chris" <ch********@pandora.be> wrote in message
news:S7**********************@phobos.telenet-ops.be...
Hi,

On a webform do I have a label, a textBox (txtName) and a submit-button (all asp server controls) :

Upon pressing the button do I write the entered name in the html-output
stream (at server site) :
private void idSubmit_Click(object sender, System.EventArgs e)
{
string str = "Thanks for filling out our survey " + txtName.Text +
"<br>";
Response.Write(str);
}

That works when I execute this in a brower but I see all the controls
displayed as well.

How can I only display the entered name as a reponse ?

thnx
Chris

Nov 18 '05 #3
ok, thanks.

is there any way you can prevent a control from rendering itself at runtime
(based on a if-condition) ?

"Hugo Wetterberg" <hu*************@smi.mas.lu.se> wrote in message
news:1f******************************@40tude.net.. .
On Thu, 09 Sep 2004 11:28:50 GMT, Chris wrote:
Hi,

On a webform do I have a label, a textBox (txtName) and a submit-button (all asp server controls) :

Upon pressing the button do I write the entered name in the html-output
stream (at server site) :
private void idSubmit_Click(object sender, System.EventArgs e)
{
string str = "Thanks for filling out our survey " + txtName.Text +
"<br>";
Response.Write(str);
}

That works when I execute this in a brower but I see all the controls
displayed as well.

How can I only display the entered name as a reponse ?

thnx
Chris


First of all: buy an ASP.NET book to read in on the fundamentals.

If you want to hide controls, use:
idSubmit.Visible=false;
txtName.Visible=false;

You should use a label control to output your message to the user. The
message may look ok, but the Click event is handled before Page.Render()
causing something like:

Thanks for filling out our survey Doe<BR>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
...
</HTML>

Which is less than perfect.

/Hugo

Nov 18 '05 #4
Yes, of course. Assume that the user queries you page using parameters in
the uri:"testpage.aspx?hideButton=yes"

then you can test this in the Page Load handler:
if(Request["hideButton"]=="yes")
idSubmit.Visible=false;

Or a more irrational condition if you want to hide the button at night:
if(DateTime.Now.Hour>20 || DateTime.Now.Hour<6)
idSubmit.Visible=false;

/Hugo

On Thu, 09 Sep 2004 12:11:59 GMT, Chris wrote:
ok, thanks.

is there any way you can prevent a control from rendering itself at runtime
(based on a if-condition) ?

"Hugo Wetterberg" <hu*************@smi.mas.lu.se> wrote in message
news:1f******************************@40tude.net.. .
On Thu, 09 Sep 2004 11:28:50 GMT, Chris wrote:
Hi,

On a webform do I have a label, a textBox (txtName) and a submit-button (all asp server controls) :

Upon pressing the button do I write the entered name in the html-output
stream (at server site) :
private void idSubmit_Click(object sender, System.EventArgs e)
{
string str = "Thanks for filling out our survey " + txtName.Text +
"<br>";
Response.Write(str);
}

That works when I execute this in a brower but I see all the controls
displayed as well.

How can I only display the entered name as a reponse ?

thnx
Chris


First of all: buy an ASP.NET book to read in on the fundamentals.

If you want to hide controls, use:
idSubmit.Visible=false;
txtName.Visible=false;

You should use a label control to output your message to the user. The
message may look ok, but the Click event is handled before Page.Render()
causing something like:

Thanks for filling out our survey Doe<BR>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
...
</HTML>

Which is less than perfect.

/Hugo

Nov 18 '05 #5
Most of them have a visible and enabled attributes. You can set both of
these to false to hide and disable them. They both have to be set to false
really in order for best performance and for best results.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Chris" <ch********@pandora.be> wrote in message
news:jM***********************@phobos.telenet-ops.be...
ok, thanks.

is there any way you can prevent a control from rendering itself at
runtime
(based on a if-condition) ?

"Hugo Wetterberg" <hu*************@smi.mas.lu.se> wrote in message
news:1f******************************@40tude.net.. .
On Thu, 09 Sep 2004 11:28:50 GMT, Chris wrote:
> Hi,
>
> On a webform do I have a label, a textBox (txtName) and a submit-button (all > asp server controls) :
>
> Upon pressing the button do I write the entered name in the html-output
> stream (at server site) :
>
>
> private void idSubmit_Click(object sender, System.EventArgs e)
> {
> string str = "Thanks for filling out our survey " + txtName.Text +
> "<br>";
> Response.Write(str);
> }
>
> That works when I execute this in a brower but I see all the controls
> displayed as well.
>
> How can I only display the entered name as a reponse ?
>
> thnx
> Chris


First of all: buy an ASP.NET book to read in on the fundamentals.

If you want to hide controls, use:
idSubmit.Visible=false;
txtName.Visible=false;

You should use a label control to output your message to the user. The
message may look ok, but the Click event is handled before Page.Render()
causing something like:

Thanks for filling out our survey Doe<BR>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
...
</HTML>

Which is less than perfect.

/Hugo


Nov 18 '05 #6
apart from setting the visible property to false, is there a way to do that
in the Page-PreRender-event handler ?

some check allowing me to prevent the rendering of a specific control on the
page
thanks
Chris

"Hugo Wetterberg" <hu*************@smi.mas.lu.se> wrote in message
news:j0****************************@40tude.net...
Yes, of course. Assume that the user queries you page using parameters in
the uri:"testpage.aspx?hideButton=yes"

then you can test this in the Page Load handler:
if(Request["hideButton"]=="yes")
idSubmit.Visible=false;

Or a more irrational condition if you want to hide the button at night:
if(DateTime.Now.Hour>20 || DateTime.Now.Hour<6)
idSubmit.Visible=false;

/Hugo

On Thu, 09 Sep 2004 12:11:59 GMT, Chris wrote:
ok, thanks.

is there any way you can prevent a control from rendering itself at runtime (based on a if-condition) ?

"Hugo Wetterberg" <hu*************@smi.mas.lu.se> wrote in message
news:1f******************************@40tude.net.. .
On Thu, 09 Sep 2004 11:28:50 GMT, Chris wrote:

Hi,

On a webform do I have a label, a textBox (txtName) and a submit-button
(all
asp server controls) :

Upon pressing the button do I write the entered name in the

html-output stream (at server site) :
private void idSubmit_Click(object sender, System.EventArgs e)
{
string str = "Thanks for filling out our survey " + txtName.Text +
"<br>";
Response.Write(str);
}

That works when I execute this in a brower but I see all the controls
displayed as well.

How can I only display the entered name as a reponse ?

thnx
Chris

First of all: buy an ASP.NET book to read in on the fundamentals.

If you want to hide controls, use:
idSubmit.Visible=false;
txtName.Visible=false;

You should use a label control to output your message to the user. The
message may look ok, but the Click event is handled before Page.Render() causing something like:

Thanks for filling out our survey Doe<BR>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
...
</HTML>

Which is less than perfect.

/Hugo

Nov 18 '05 #7
I don't know what you're after, setting Visible to false prevents the
rendering of the control. The metod void Render(HtmlTextWriter) for the
control never gets executed. It doesn't matter if you do this in Load or
PreRender, rendering is completely prevented anyway.

/Hugo

On Thu, 09 Sep 2004 16:18:21 GMT, Chris wrote:
apart from setting the visible property to false, is there a way to do that
in the Page-PreRender-event handler ?

some check allowing me to prevent the rendering of a specific control on the
page
thanks
Chris

"Hugo Wetterberg" <hu*************@smi.mas.lu.se> wrote in message
news:j0****************************@40tude.net...
Yes, of course. Assume that the user queries you page using parameters in
the uri:"testpage.aspx?hideButton=yes"

then you can test this in the Page Load handler:
if(Request["hideButton"]=="yes")
idSubmit.Visible=false;

Or a more irrational condition if you want to hide the button at night:
if(DateTime.Now.Hour>20 || DateTime.Now.Hour<6)
idSubmit.Visible=false;

/Hugo

On Thu, 09 Sep 2004 12:11:59 GMT, Chris wrote:
ok, thanks.

is there any way you can prevent a control from rendering itself at runtime (based on a if-condition) ?

"Hugo Wetterberg" <hu*************@smi.mas.lu.se> wrote in message
news:1f******************************@40tude.net.. .
On Thu, 09 Sep 2004 11:28:50 GMT, Chris wrote:

> Hi,
>
> On a webform do I have a label, a textBox (txtName) and a submit-button (all
> asp server controls) :
>
> Upon pressing the button do I write the entered name in the html-output> stream (at server site) :
>
>
> private void idSubmit_Click(object sender, System.EventArgs e)
> {
> string str = "Thanks for filling out our survey " + txtName.Text +
> "<br>";
> Response.Write(str);
> }
>
> That works when I execute this in a brower but I see all the controls
> displayed as well.
>
> How can I only display the entered name as a reponse ?
>
> thnx
> Chris

First of all: buy an ASP.NET book to read in on the fundamentals.

If you want to hide controls, use:
idSubmit.Visible=false;
txtName.Visible=false;

You should use a label control to output your message to the user. The
message may look ok, but the Click event is handled before Page.Render() causing something like:

Thanks for filling out our survey Doe<BR>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
...
</HTML>

Which is less than perfect.

/Hugo

Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Ricardo | last post by:
Hi. How should I pass a " (doble-quote) character to response.write() in order for it to be sent to the output ? Thanks in advance for the help.
0
by: Copa | last post by:
Hello, I am testing buffering an asp page and Flushing information out to the browser, hence i wrote the code in an asp page that follows this Message Post. The loops are suppose to simulate...
2
by: Rob McLennan - ZETLAND | last post by:
Hi, I'm relatively clueless when it comes to correct ASP syntax. I'm testing out a search form for my company's website which is done in ASP. The results are displayed as per the code shown at the...
3
by: Gary | last post by:
I am having a strange problem that I cannot solve. I have an asp page that I use for a user to login and gain access to other pages. When the user logs in I set a couple of session variables like...
9
by: Dominic Godin | last post by:
Hi, I have an asp page that does a lot of processing and reports it's finished by printing the word "Success". For example: <% SomeFunction(SomeVar) SomeFunction(SomeVar1) ...
13
by: TinyTim | last post by:
I'm a newbie at ASP & HTML. It seems that when you use server side code and you're going to return a customized HTML form with several fields and labels, you have to do an extensive amount of...
5
by: Luiz Vianna | last post by:
Guys, I need to send some info to my client while I'm processing some stuff. The flow will be something like : -process -response -process -response .... I imagine to use response.flush...
0
by: jose.mendez22 | last post by:
I'm trying to fire a pop-up window before I execute a lengthy stored procedure so I may utilize this window as a status window on number of records executed. After my response.write statements...
6
by: john | last post by:
The standard method to transmit a file from an aspx page to a browser is to stream the file to the response then end the response. The HTML code generated by the aspx page is discarded, and the...
4
by: cbtechlists | last post by:
I have an ASP app that we've moved from a Windows 2000 to a Windows 2003 server (sql server 2000 to sql server 2005). The job runs fine on the old servers. Part of the app takes a recordset and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.