Response.Write() ??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris

    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.EventArg s 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


  • Hugo Wetterberg

    #2
    Re: Response.Write( ) ??

    On Thu, 09 Sep 2004 11:28:50 GMT, Chris wrote:
    [color=blue]
    > 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.EventArg s 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[/color]

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

    If you want to hide controls, use:
    idSubmit.Visibl e=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

    Comment

    • Eliyahu Goldin

      #3
      Re: Response.Write( ) ??

      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" <christianc@pan dora.be> wrote in message
      news:S7X%c.2412 25$UN.12176478@ phobos.telenet-ops.be...[color=blue]
      > Hi,
      >
      > On a webform do I have a label, a textBox (txtName) and a submit-button[/color]
      (all[color=blue]
      > 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.EventArg s 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
      >
      >[/color]


      Comment

      • Chris

        #4
        Re: Response.Write( ) ??

        ok, thanks.

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

        "Hugo Wetterberg" <hugo.wetterber g@smi.mas.lu.se > wrote in message
        news:1flsx9og4n 8oc$.14f0udivjy 9bo.dlg@40tude. net...[color=blue]
        > On Thu, 09 Sep 2004 11:28:50 GMT, Chris wrote:
        >[color=green]
        > > Hi,
        > >
        > > On a webform do I have a label, a textBox (txtName) and a submit-button[/color][/color]
        (all[color=blue][color=green]
        > > 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.EventArg s 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[/color]
        >
        > First of all: buy an ASP.NET book to read in on the fundamentals.
        >
        > If you want to hide controls, use:
        > idSubmit.Visibl e=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[/color]


        Comment

        • Hugo Wetterberg

          #5
          Re: Response.Write( ) ??

          Yes, of course. Assume that the user queries you page using parameters in
          the uri:"testpage.a spx?hideButton= yes"

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

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

          /Hugo

          On Thu, 09 Sep 2004 12:11:59 GMT, Chris wrote:
          [color=blue]
          > ok, thanks.
          >
          > is there any way you can prevent a control from rendering itself at runtime
          > (based on a if-condition) ?
          >
          > "Hugo Wetterberg" <hugo.wetterber g@smi.mas.lu.se > wrote in message
          > news:1flsx9og4n 8oc$.14f0udivjy 9bo.dlg@40tude. net...[color=green]
          >> On Thu, 09 Sep 2004 11:28:50 GMT, Chris wrote:
          >>[color=darkred]
          >>> Hi,
          >>>
          >>> On a webform do I have a label, a textBox (txtName) and a submit-button[/color][/color]
          > (all[color=green][color=darkred]
          >>> 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.EventArg s 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[/color]
          >>
          >> First of all: buy an ASP.NET book to read in on the fundamentals.
          >>
          >> If you want to hide controls, use:
          >> idSubmit.Visibl e=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[/color][/color]

          Comment

          • Mark Fitzpatrick

            #6
            Re: Response.Write( ) ??

            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" <christianc@pan dora.be> wrote in message
            news:jMX%c.2412 59$H43.12307562 @phobos.telenet-ops.be...[color=blue]
            > ok, thanks.
            >
            > is there any way you can prevent a control from rendering itself at
            > runtime
            > (based on a if-condition) ?
            >
            > "Hugo Wetterberg" <hugo.wetterber g@smi.mas.lu.se > wrote in message
            > news:1flsx9og4n 8oc$.14f0udivjy 9bo.dlg@40tude. net...[color=green]
            >> On Thu, 09 Sep 2004 11:28:50 GMT, Chris wrote:
            >>[color=darkred]
            >> > Hi,
            >> >
            >> > On a webform do I have a label, a textBox (txtName) and a submit-button[/color][/color]
            > (all[color=green][color=darkred]
            >> > 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.EventArg s 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[/color]
            >>
            >> First of all: buy an ASP.NET book to read in on the fundamentals.
            >>
            >> If you want to hide controls, use:
            >> idSubmit.Visibl e=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[/color]
            >
            >[/color]


            Comment

            • Chris

              #7
              Re: Response.Write( ) ??

              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" <hugo.wetterber g@smi.mas.lu.se > wrote in message
              news:j0wpzdcal2 7h.1k4h49phkh4m 9.dlg@40tude.ne t...[color=blue]
              > Yes, of course. Assume that the user queries you page using parameters in
              > the uri:"testpage.a spx?hideButton= yes"
              >
              > then you can test this in the Page Load handler:
              > if(Request["hideButton "]=="yes")
              > idSubmit.Visibl e=false;
              >
              > Or a more irrational condition if you want to hide the button at night:
              > if(DateTime.Now .Hour>20 || DateTime.Now.Ho ur<6)
              > idSubmit.Visibl e=false;
              >
              > /Hugo
              >
              > On Thu, 09 Sep 2004 12:11:59 GMT, Chris wrote:
              >[color=green]
              > > ok, thanks.
              > >
              > > is there any way you can prevent a control from rendering itself at[/color][/color]
              runtime[color=blue][color=green]
              > > (based on a if-condition) ?
              > >
              > > "Hugo Wetterberg" <hugo.wetterber g@smi.mas.lu.se > wrote in message
              > > news:1flsx9og4n 8oc$.14f0udivjy 9bo.dlg@40tude. net...[color=darkred]
              > >> 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[/color][/color][/color]
              submit-button[color=blue][color=green]
              > > (all[color=darkred]
              > >>> asp server controls) :
              > >>>
              > >>> Upon pressing the button do I write the entered name in the[/color][/color][/color]
              html-output[color=blue][color=green][color=darkred]
              > >>> stream (at server site) :
              > >>>
              > >>>
              > >>> private void idSubmit_Click( object sender, System.EventArg s 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.Visibl e=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[/color][/color][/color]
              Page.Render()[color=blue][color=green][color=darkred]
              > >> 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[/color][/color][/color]


              Comment

              • Hugo Wetterberg

                #8
                Re: Response.Write( ) ??

                I don't know what you're after, setting Visible to false prevents the
                rendering of the control. The metod void Render(HtmlText Writer) 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:
                [color=blue]
                > 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" <hugo.wetterber g@smi.mas.lu.se > wrote in message
                > news:j0wpzdcal2 7h.1k4h49phkh4m 9.dlg@40tude.ne t...[color=green]
                >> Yes, of course. Assume that the user queries you page using parameters in
                >> the uri:"testpage.a spx?hideButton= yes"
                >>
                >> then you can test this in the Page Load handler:
                >> if(Request["hideButton "]=="yes")
                >> idSubmit.Visibl e=false;
                >>
                >> Or a more irrational condition if you want to hide the button at night:
                >> if(DateTime.Now .Hour>20 || DateTime.Now.Ho ur<6)
                >> idSubmit.Visibl e=false;
                >>
                >> /Hugo
                >>
                >> On Thu, 09 Sep 2004 12:11:59 GMT, Chris wrote:
                >>[color=darkred]
                >>> ok, thanks.
                >>>
                >>> is there any way you can prevent a control from rendering itself at[/color][/color]
                > runtime[color=green][color=darkred]
                >>> (based on a if-condition) ?
                >>>
                >>> "Hugo Wetterberg" <hugo.wetterber g@smi.mas.lu.se > wrote in message
                >>> news:1flsx9og4n 8oc$.14f0udivjy 9bo.dlg@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[/color][/color]
                > submit-button[color=green][color=darkred]
                >>> (all
                >>>>> asp server controls) :
                >>>>>
                >>>>> Upon pressing the button do I write the entered name in the[/color][/color]
                > html-output[color=green][color=darkred]
                >>>>> stream (at server site) :
                >>>>>
                >>>>>
                >>>>> private void idSubmit_Click( object sender, System.EventArg s 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.Visibl e=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[/color][/color]
                > Page.Render()[color=green][color=darkred]
                >>>> 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[/color][/color][/color]

                Comment

                Working...