how does viewstate appear?

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

    #1

    how does viewstate appear?

    i am having problems after problems...

    first i tried to create a page template and finally got that to work. so
    currently all my pages inherit from a template page class.

    i am adding controls to my page dynamically (so my html designer has no html
    code in it). the problem is if i view the source of my page in my browser
    there is no viewstate control.

    how do i get this to appear? dont i need this to use server controls?


  • Karl Seguin

    #2
    Re: how does viewstate appear?

    you need a <form runat="server"> </form> in there in order for viewstate to
    work.

    Karl

    "suzy" <me@nospam.co m> wrote in message
    news:uq5RJnoVDH A.1816@TK2MSFTN GP09.phx.gbl...[color=blue]
    > i am having problems after problems...
    >
    > first i tried to create a page template and finally got that to work. so
    > currently all my pages inherit from a template page class.
    >
    > i am adding controls to my page dynamically (so my html designer has no[/color]
    html[color=blue]
    > code in it). the problem is if i view the source of my page in my browser
    > there is no viewstate control.
    >
    > how do i get this to appear? dont i need this to use server controls?
    >
    >[/color]


    Comment

    • suzy

      #3
      Re: how does viewstate appear?

      hi,

      i have that in my code but it isn't working. do you think it's because i am
      using a page template and inheriting from another page template class?

      i have added the following line to my template class
      ....

      Controls.Add (new LiteralControl ("<form id='frmbody' name='frmBody'
      method='post' runat='server'> "));

      Controls.Add (Body); // this is a placeholder

      Controls.Add (new LiteralControl ("</form>"));

      ....


      "Karl Seguin" <kseguin##crea. ca> wrote in message
      news:ODlsqSpVDH A.2260@TK2MSFTN GP09.phx.gbl...[color=blue]
      > you need a <form runat="server"> </form> in there in order for viewstate to
      > work.
      >
      > Karl
      >
      > "suzy" <me@nospam.co m> wrote in message
      > news:uq5RJnoVDH A.1816@TK2MSFTN GP09.phx.gbl...[color=green]
      > > i am having problems after problems...
      > >
      > > first i tried to create a page template and finally got that to work.[/color][/color]
      so[color=blue][color=green]
      > > currently all my pages inherit from a template page class.
      > >
      > > i am adding controls to my page dynamically (so my html designer has no[/color]
      > html[color=green]
      > > code in it). the problem is if i view the source of my page in my[/color][/color]
      browser[color=blue][color=green]
      > > there is no viewstate control.
      > >
      > > how do i get this to appear? dont i need this to use server controls?
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Kevin Spencer

        #4
        Re: how does viewstate appear?

        Unless you're adding controls to a WebForm (<form runat=server... >), you
        won't HAVE any ViewState, and your Server Controls won't work properly.

        --
        HTH,

        Kevin Spencer
        Microsoft MVP
        ..Net Developer
        All hotels in Benidorm. The best selection of Benidorm hotels with reviews and maps. Book in advance and save.

        Complex things are made up of
        lots of simple things.

        "suzy" <me@nospam.co m> wrote in message
        news:uq5RJnoVDH A.1816@TK2MSFTN GP09.phx.gbl...[color=blue]
        > i am having problems after problems...
        >
        > first i tried to create a page template and finally got that to work. so
        > currently all my pages inherit from a template page class.
        >
        > i am adding controls to my page dynamically (so my html designer has no[/color]
        html[color=blue]
        > code in it). the problem is if i view the source of my page in my browser
        > there is no viewstate control.
        >
        > how do i get this to appear? dont i need this to use server controls?
        >
        >[/color]


        Comment

        • Karl Seguin

          #5
          Re: how does viewstate appear?

          don't think that would work...instead of adding a literalcontrol that has an
          html form...try adding an HtmlControls.Ht mlForm...

          HtmlForm Form = new HtmlForm();
          HtmlForm.Contro ls.Add(Body)
          Controls.Add(Ht mlForm)

          make sure to add ur body to your form....and then the form to the containing
          control.

          this quasy-quality article might help:


          Karl


          "suzy" <me@nospam.co m> wrote in message
          news:eoH90epVDH A.2248@TK2MSFTN GP10.phx.gbl...[color=blue]
          > hi,
          >
          > i have that in my code but it isn't working. do you think it's because i[/color]
          am[color=blue]
          > using a page template and inheriting from another page template class?
          >
          > i have added the following line to my template class
          > ...
          >
          > Controls.Add (new LiteralControl ("<form id='frmbody' name='frmBody'
          > method='post' runat='server'> "));
          >
          > Controls.Add (Body); // this is a placeholder
          >
          > Controls.Add (new LiteralControl ("</form>"));
          >
          > ...
          >
          >
          > "Karl Seguin" <kseguin##crea. ca> wrote in message
          > news:ODlsqSpVDH A.2260@TK2MSFTN GP09.phx.gbl...[color=green]
          > > you need a <form runat="server"> </form> in there in order for viewstate[/color][/color]
          to[color=blue][color=green]
          > > work.
          > >
          > > Karl
          > >
          > > "suzy" <me@nospam.co m> wrote in message
          > > news:uq5RJnoVDH A.1816@TK2MSFTN GP09.phx.gbl...[color=darkred]
          > > > i am having problems after problems...
          > > >
          > > > first i tried to create a page template and finally got that to work.[/color][/color]
          > so[color=green][color=darkred]
          > > > currently all my pages inherit from a template page class.
          > > >
          > > > i am adding controls to my page dynamically (so my html designer has[/color][/color][/color]
          no[color=blue][color=green]
          > > html[color=darkred]
          > > > code in it). the problem is if i view the source of my page in my[/color][/color]
          > browser[color=green][color=darkred]
          > > > there is no viewstate control.
          > > >
          > > > how do i get this to appear? dont i need this to use server controls?
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          Working...