Response.Write() ?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.aspnet.

Post a new message to this list...

Chris
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

Reply to this message...
 
    
Eliyahu Goldin
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" <Click here to reveal e-mail address> wrote in message
news:S7X%c.241225$Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Hugo Wetterberg
On Thu, 09 Sep 2004 11:28:50 GMT, Chris wrote:

[Original message clipped]

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
Reply to this message...
 
    
Chris
ok, thanks.

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

"Hugo Wetterberg" <Click here to reveal e-mail address> wrote in message
news:1flsx9og4n8oc$.Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Mark Fitzpatrick
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" <Click here to reveal e-mail address> wrote in message
news:jMX%c.241259$Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Hugo Wetterberg
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:

[Original message clipped]

Reply to this message...
 
    
Chris
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" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Hugo Wetterberg
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:

[Original message clipped]

Reply to this message...
 
 
System.DateTime
System.EventArgs
System.Web.UI.HtmlTextWriter
System.Web.UI.Page




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com