Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Goran #1
ClearChildViewState does not clear the state in Composite Control
Hi all,
I'm developing a custom user control loader. The idea is to have a
templated control that maintains a list of user controls (ASCX files) and
then according a specified index, it loads the appropriate user control. To
select one control, a tabbed list is displayed followed by a DIV where the
selected user control is loaded.
I managed to get most things working, including events and state management,
apart from one thing. The problem I have is that when I want to reset/flush
the ViewState of a newly loaded user control (happens when switching between
tabs, i.e. user controls), some of its initial view state is still there.
(The reasoning behind this is so that the control can be treated as if it is
loaded for the first time and as a result, to perform any
databinding/initialisation it needs to do.)
For code snippets, please see below.
Thanks,
Goran
===============================================
So, I started with something along this lines in C#:
===============================================
[ParseChildren(true,"ControlDescriptors")]
public class UserControlsLoader : System.Web.UI.TemplateControl {
...
public ArrayList ControlDescriptors { get ... }
...
protected override void OnInit(EventArgs e)
{
base.OnInit (e);
if(this.Page.IsPostBack)
{
this.PerformSelection(); //it checks if the current control
needs to change from some page-registered hidden fields
if(this.IsSelectionChanged)
{
this.ClearChildViewState();
OnUserControlChanged(new
UserControlChangedArgs(this.SelectedTab)); //raises a custom event
}
}
}
....
protected override void CreateChildControls() {
//loads the HtmlControls for the tabs + the selected user
control
}
}
===============================================
I use the following in an ASPX page:
===============================================
<%@ Register TagPrefix="QQ" Namespace="xx" Assembly="xx" %>
.....
<QQ:UserControlsLoader id="qq" runat="server" SomeProperty="value">
<QQ:UserControlDescriptor Visible="true" Source="~/Components/uc1.ascx"
Name="First" />
<QQ:UserControlDescriptor Visible="true" Source="~/Components/uc2.ascx"
Name="Second" />
</QQ:UserControlsLoader>
===============================================
Goran Guest
-
Losing Postback state with composite controls
Not sure how to go about explaining this, which is never a good sign. I have a Custom UserControl I've built, which contains 1 drop-down list and... -
Losing Composite Control property that another Composite Control ...
Hi, I'm creating 2 composite controls in ASP.net. Control 1 is a Search control and control 2 is a Map control. I have added a property... -
Possible to create a composite control that has a child control that is a validator that validates the composite control itself?
I am attempting to create a composite control which has a label, followed by an optional error message, followed by two text boxes. I have... -
Custom Composite Control, child User-controls loosing view state
I've created composite custom control which dynamically creates and arranges it's child controls based on some xml data. Beside the simple web form... -
Using Table control in a custom composite control. Control does not render properly in design time.
All, I have written a very simple custom composite control that includes a control of type System.Web.UI.WebControls.Table. The control... -
Unregistered #2
ClearChildViewState does not clear the state in Composite Control
Hi,
Which solution did you find for this problem ?
Thanks,
Nico.Unregistered Guest



Reply With Quote

