Best option for persisting pageview contents?

M

mawi

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>
 
M

mawi

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top