Best option for persisting pageview contents?

Discussion in 'ASP .Net Web Controls' started by mawi, Jul 8, 2004.

  1. mawi

    mawi Guest

    Hello again,

    I posted this question without code, here is the code.

    Again, the problem is: Viewstate of a pageviews child
    controls is not saved as it would be if the control were
    child of the page.

    Any clues as to how to resolve this in the best way are
    greatly appreciated. If one could make a control child of
    multiple parents I could use Denis Bauers placeholder, but
    afaik that is not possible.

    Notice that this will probably not run using vanilla ie
    webcontrols code, due to the bug I've posted about recently.

    /mawi

    Code (save as aspx file in a webroot, put
    "Microsoft.Web.UI.WebControls.dll" - preferably bugfixed -
    in "bin" directory of that root):

    <%@ Page language="c#" AutoEventWireup="true" %>
    <%@ Register TagPrefix="iewc"
    Namespace="Microsoft.Web.UI.WebControls"
    Assembly="Microsoft.Web.UI.WebControls" %>
    <script runat="server">
    void Page_Load()
    {
    for ( int i = 1; i <= TabStrip1.Items.Count; i++ )
    NewPV( i.ToString() );
    }
    private void addTab(object sender, System.EventArgs e)
    {
    String count = (TabStrip1.Items.Count + 1).ToString();
    Tab t = new Tab();
    t.Text = t.ID = "Tab_" + count;
    PageView pv = NewPV( count );
    t.TargetID = pv.ID;
    pv.Controls.Add( new Label() );
    ( pv.Controls[ 1 ] as Label ).Text = "Persist this!!";
    TabStrip1.Items.Add( t );
    }
    private PageView NewPV( String count )
    {
    PageView pv = new PageView();
    pv.Controls.Add( new Literal() );
    ( pv.Controls[ 0 ] as Literal ).Text = "<H1>Page for tab
    " + count + "</H1>";
    MultiPage1.Controls.Add( pv );
    pv.ID = "page_" + count;
    return pv;
    }
    </script>
    <html>
    <body>
    <form runat="server">
    <asp:button id="addBtn" runat="server" Text="+Tab"
    OnClick="addTab" />
    <iewc:tabstrip id="TabStrip1" runat="server"
    targetid="MultiPage1" />
    <iewc:multipage id="MultiPage1" runat="server" />
    </form>
    </body>
    </html>
    mawi, Jul 8, 2004
    #1
    1. Advertising

  2. mawi

    mawi Guest

    Hi,

    actually my code was in error on this. Viewstate if child
    controls of pageviews is persisted. Corrected code follows
    (note that it requires the bugfix I posted recently to work).


    <%@ Page language="c#" AutoEventWireup="true" %>
    <%@ Register TagPrefix="iewc"
    Namespace="Microsoft.Web.UI.WebControls"
    Assembly="Microsoft.Web.UI.WebControls" %>
    <script runat="server">
    void Page_Load()
    {
    for ( int i = 1; i <= TabStrip1.Items.Count; i++ )
    NewPV( i.ToString() );
    }
    private PageView NewPV( String count )
    {
    PageView pv = new PageView();
    pv.Controls.Add( new Literal() );
    pv.Controls.Add( new Label() );
    MultiPage1.Controls.Add( pv );
    pv.ID = "page_" + count;
    return pv;
    }
    private void addTab(object sender, System.EventArgs e)
    {
    String count = (TabStrip1.Items.Count + 1).ToString();
    Tab t = new Tab();
    t.Text = t.ID = "Tab_" + count;
    PageView pv = NewPV( count );
    t.TargetID = pv.ID;
    ( pv.Controls[ 1 ] as Label ).Text = "Persist this!!";
    ( pv.Controls[ 0 ] as Literal ).Text = "<H1>Page for tab
    " + count + "</H1>";
    TabStrip1.Items.Add( t );
    }
    </script>
    <html>
    <body>
    <form runat="server">
    <asp:button id="addBtn" runat="server" Text="Add Tab"
    OnClick="addTab" />
    <iewc:tabstrip id="TabStrip1" runat="server"
    targetid="MultiPage1" />
    <iewc:multipage id="MultiPage1" runat="server" />
    </form>
    </body>
    </html>
    mawi, Jul 9, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. szabelin
    Replies:
    1
    Views:
    1,573
    Teemu Keiski
    Aug 20, 2003
  2. RedEagle
    Replies:
    0
    Views:
    466
    RedEagle
    Aug 20, 2004
  3. gce
    Replies:
    0
    Views:
    416
  4. elad

    Adding dynamic controls to pageview - set location

    elad, Nov 6, 2003, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    110
  5. mawi

    Persist multipage pageview contents?

    mawi, Jul 7, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    123
Loading...

Share This Page