Using IStateManager for web control collections

Hi, 

Here's my situation. I have a web control I call CommandBar that renders as a table containing a collection of CommandButton objects which are also WebControls, that it render within TableCells.
I basically wanted the user to be able to dyanamically add 1..N CommandButton controls to the CommandBar through code behind. I'm not sure how I should implement the code to do this.
1. Should I simply expose and Add() method and add each CommandBar to the CommandBar.Controls collection? The client code-behind would look something like.
CommandBar cmdBar = new CommandBar(); 

cmdBar.Add(new CommandButton("Ok"));
cmdBar.Add(new CommandButton("Cancel"));
cmdBar.Add(new CommandButton("Help"));
this.Controls.Add(cmdBar);
2. Or, should I implement a CommandButtonCollection, populate it with CommandButton objects) and add that to the CommandBar? Code would look like...
CommandBar cmdBar = new CommandBar(); 

CommandButtonCollection buttons = new CommandBarCollection();
buttons.Add(new CommandButton("Ok"));
buttons.Add(new CommandButton("Cancel"));
buttons.Add(new CommandButton("Help"));
cmdBar.Items = buttons;
this.Controls.Add(cmdBar);
I've looked at some great examples on how to serialize Custom Types into a collection class using IStateManager on the items within the collection and the collection itself, yet it seems like I should be able to use the default ViewState implementation for the CommandButton objects since it inherits from WebControl. But what about the CommandBarCollection?
Is there a recommended way of implementing a WebControl that maintains a a custom typed collection of other web controls?
Thanks for any help anyone can provide.
0
jbucci
8/6/2003 1:27:16 PM
asp.net.state-management 8807 articles. 0 followers. Follow

0 Replies
811 Views

Similar Articles

[PageSpeed] 4

Reply:

Similar Artilces:

Using IStateManager for a web control collection
Hi, Here's my situation. I have a web control I call CommandBar that renders as a table containing a collection of CommandButton objects which are also WebControls, that it render within TableCells. I basically wanted the user to be able to dyanamically add 1..N CommandButton controls to the CommandBar through code behind. I'm not sure how I should implement the code to do this. 1. Should I simply expose and Add() method and add each CommandBar to the CommandBar.Controls collection? The client code-behind would look something like. CommandBar cmdBar = new CommandBar(); ...

Use Web Control In a Web Control
Is this possible?I am working with an aspx page that consists of many different web controls.One of the web controls contains search criteria.  One of the criteria is a date range where I am trying to add a popup calendar --> which is another web controlCan I register the popupcaledar control on the questionaire control?  I have tried, but nothing seems to be registered.Any ideas will GREATLY help.Relax and have some Home Brew!Prosecute the Owner - Don't PERSECUTE the Breed!Breed Specific Legislation targets the WRONG end of the LEASH! Without seeing your code we can'...

I have a web user control being used by another web user control, but the one being used will not display the labels in the resx file.
I am using DotNetNuke version 3.13 (might be 3.013) on a Window's XP machine, SP2. I have what I find to be an extremely odd situation. I have a project called TDS.Controls. This project is a web control library. Each control has its own resx file, which is located in the App_LocalResources directory. Each control inherits from Framework.UserControlBase, just like DotNetNuke's User control in DNN\Controls\User.ascx.vb. As a matter of fact, this control is doing the exact same thing I am trying to do. It is a web user control with its own resx file being used by another web user control (See ...

Use Web Custom control or Web User control?
Friends,  I have a generic aspx page and its functions which is used in many .NET web application. The generic page contains a HTML Div control, server drop down list, server buttons, server textbox and it have different server and client functions to do its tasks for calling aspx pages in web applications. My problem is I do not know whether I should make that generic page as a web user control (but this is tedious because all other application folders must store frontpage aspx and code behind files of the generic page) or as a web custom control (This seems to be good beca...

State Management using Controls
Hi,1. How to maintain state management using controls GridView, Datagrid, Dataview ?2. What other controls are used/can be used in/for state management? Thanks  check this article http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx"Never underestimate the power of stupid people in large groups" By default all ASP.NET controls have a state called "View State" and it is Enabled by default. to Disable/Enable control state simply change EnableViewState propertyGridView1.EnableViewState=false; DataGrid1.EnableViewState=true;  Kh...

web controls state management
Hi,      I have a search page with N of textBoxes. If suppose, we enter "firstname" in a textbox , it takes you to the other page which display the list with that firstname. There is a back button in that page and when I click it. it go back to search page with clearing the textbox value.I want to retain the page control values when the user return to search page. Is it possible to retain the textbox value when we come back to page? Thanks Nitham I beleive you would want to store the values of your text boxes in variables and do an If Page.IsPostBack, text boxes = v...

How to get the HREF value of the Anchor tag in a web page using the web browser control in vb.net
Hi Friends,               i have a webserver control in my application.i load the web browser control on a button click using the below code Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click                AxWebBrowser1.Navigate("http://www.rateitall.com/i-322335-.aspx", False) End sub once the page is loaded in the browser i want the <a> HREF value in that page.For example if that page has ...

Can you return .net web controls in a .net page from a web service?
I've got a problem with a project. I've got to compile an entire .net page and return it as part of a Web Service for display. The problem I have is that I need to add WebControls and functionality to the page so that not only the html content and images are displayed (which I've managed) but that textboxes, labels, buttons and datasets can be displayed also. Essentially I need to make a call from one site for a page, populate the page and return it in a state as though it resided on the same server/webspace as the calling page. Code is currently built as follows into a string: strOpenHT...

Session state management using web services.
 Hi all ,i am working of a hospital management system which we desided to develop using atlas frame work. we have created the application main to sections using atlas script call back architecture. we are using scripts to pack the user entered data to the web service and in that web service we are entering the data in to the database.all this happening with out a post back of the page.now comes the problem. we are not being able to handle the user session properties. we came to know that we cant access session variables in web services. we are in a trap now. how we can manage the sessio...

web control collection property with each object in collection having a collection property
I have been trying to build a web control with a collection property and each object in the collection having its own collection property. It needs to be a nested collection with in the control. I am able to successfully create a collection property with in the control, use the collection editor to add “layers” and I am also able to create a collection property for each “layer” and add “symbols” to the “Symbols” collection. My problem lies in getting the control to write the html code for the control so that it can be parsed. Something that would look like this: <cc1:MapLayerList id="Map...

Using a multimedia .NET Winform control in a web page
Hello,I have created a multimedia .NET Winform control. It lets you capture video from your webcam and saves it to a local .AVI file. I am using DirectShow.NET to achieve this. This control works great when I include it in a Windows Form. But when I try to use it in a web page with the 'OBJECT' tag, it fails to run.I debugged it and found that the moment I run the DirectShow code which detects the cameras on your sytem, the control fails to run in the web page. i.e. If I don't call DirectShow, it works, if i call it doesn't.Since DirectShow is the core functionality of the co...

Who uses Web Controls/HTML Controls?
I'm currently making the migration from ColdFusion to asp.net and I have a few questions. 1. Does anybody really use the Web/HTML Controls? CF has something similar <cfform> but I never use it because I'm a believer in separating html from application logic/control. And I like being in control of what goes on in my apps. However, I find the Web/HTML Controls interesting. 2. Is there a standard framework that people use to organize their code? I like using MVC (Model, View, Controller) to create true N-tier applications. Just wondering what others use. 3. Is anybody using Flash...

Not install Web Controls to use these controls?
Dear All, Can anyone tell me how to use the web controls if I did not install the web contols from the downloaded .exe files? Many thanks if you can give me code with vb Lan. Regards Can you tell us what you did (step by step) and where it's not working? Please, view post 134991. DNN skins ForumTressleworks modulesDNN & webhostingIEWCtrls...

What control do I use (or do I not use a control at all...)
Okay so here's the story so far. I am making a blog to be incorporated into a website. Well, I'm doing the blog from scratch. I'm using MySQL to source all the data via MySQL .NET/Connector. Now while developing the script, I used DataReader and Response.Write to show the blog topics. Now that it has come to put it under a design (I'm using a Master Page for that), I've hit the problem. Response.Write shows all the topics before any of the design elements could be incorporated. So that (more or less) is out of question. So next I looked into the data presentation controls. I looked up GridVi...

Web resources about - Using IStateManager for web control collections - asp.net.state-management

Resources last updated: 1/15/2016 6:28:10 AM