.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

custom server control with custom child collection,get the collection?

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :ASP.Net
Hi!I want to create a custom server control, that then will have a custom child collection.The thing is that I also want to be able to modify the custom childs from the custom server control classFor example I have a row of cards, and the class is called CardRow, a CardRow is simply a class full of the class card in this case, se the class "Card" down below:using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Collections.Generic; namespace MemoryLib { [ToolboxData("<{0}:CardRow runat=server></{0}:CardRow>")] public class CardRow : WebControl { public List<Card> _Card; [PersistenceMode(PersistenceMode.InnerProperty)] public List<Card> Card { get { return _Card; } set { _Card = value; } } public CardRow() { } protected override void CreateChildControls() { } protected override void Render(HtmlTextWriter writer) { } } } using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace MemoryLib

View Complete Post

More Related Resource Links

Custom Control Collection Serialization

Hello All, (VB2005) I've created a custom graph control that has a collection of GraphPlots.  When adding the plots at design time, I wanted the name of the GraphPlot to auto increment in the collection window.  Just like when you add controls to a form: i.e. TextBox1, TextBox2, etc. So in the GraphPlot class, I made it inherit from component and it works.  The problem is when the graph itself is deleted from the form.  The GraphPlot objects do not get removed from the form designer.  For example, I add 2 GraphPlots (GraphPlot1 & GraphPlot2), then I delete the graph from the form.  Then I add a graph to the form again and add a GraphPlot. The first one added starts at 3 (GraphPlot3) because 1 and 2 are still in the form designer code. My GraphPlotCollection class inherits from collectionbase.  I didn't use a type converter or a collection editor.  Didn't need them to make everything work.... almost everything I couldn't find any good info on this so I figure its time for some help from the experts. Thanks for any suggestions -

Custom Control Controls Collection

I have an ASP.NET custom control with several asp:panel controls that have various questions for users in them. When the control loads I need to set a Session object to the default panel (first question). This worked when I had the objects and code in a web form, but I moved them to a custom web control, and now when I try to access that control in the Load event of the custom control it says the default panel control is null. It seems that the controls are not created when the Load event is firing. Evidently the order of loading controls is different between web forms and custom controls. Can someone explain to me where the controls inside the custom control will become available to use? Thanks for the help! 

Binding to an observable collection in a custom WPF control


Hi everyone,

I'll first explain a bit what I'm doing so that the code paste will make a bit more sense. I'm creating a circular menu control for Microsoft Surface (this question is far from Surface specific though, but otherwise this type of control wouldn't make sense :) ), it has some 'pieces' which are all buttons. I've created a 'Menu' control which contains the menu items, I made a custom control for these items (so I could add them to the menu within XAML), and I made a Button control which actually does the drawing of the path etc. I've done this in this specific way because the angle of the button's path will depend on the number of pieces within the menu. Anyway the above all works fine and dandy and I'm happy with the result. However now I'm trying to get all of this to work.

What I want to do is to use MVVM in my application and bind the MenuItems to a command in my ViewModel. So I have an AdminToolbox which is a view containing the menu and there's an AdminToolboxViewModel which is the ViewModel with the command and the items that I'd need to bind to my menu to create the menu items.

Some code pastes:



video tutorial link for composite and rendered custom server control


hii all

i am new to technology so go easy on this post

according to what i read from web there are 3 type of custom server controls

1 superclass

2 composite

3 rendered

i found video tutorial for superclass custom server control but couldnt find video tutials for other 2.

please forward me link for composite and rendered custom server controls video tutorial  

image inside custom server control



I want to use an image inside a Custom Web server control ! 

Do I need to use Web.resources ? if so , how to do ?

Custom Server Control Property not maintaining state


I have created a server control consisting of a TextArea and a div under it.  My goal is to create my own asp:TextArea type control.  the div is for a Character count of the text area and seems to work ok but i added a CharacterCountVisible property to the control that is always returning true.  See Proptery definition below


<Bindable(False), Category("Appearance"), DefaultValue("True"), Localizable(True)> Property CharacterCountVisible() As Boolean
        Return _CountBoxVisible
    End Get
    Set(ByVal value As Boolean)
        _CountBoxVisible = value
    End Set
End Property

Note the _CountBoxVisible variable is define inside the class as :

Dim _CountBoxVisible as Boolean = True

What I am trying to do is give the user/coder the option to show/utilize the char count feature.  Can make it disappear with textarea1.CharacterCountVisible = False but setting it to true will not make it display.


What am i missing





Removing a (child) user control from an observable collection

Hey all, so I have an ObservableCollection of UserControls.  These user controls have their own xaml and each of these has some type of "Close" button so it would be removed from the ObservableCollection. A groupbox is binded to the ObservableCollection so it would show all the UserControls.  When a user clicks on the "Close" button, the user control is removed from the ObservableCollection and thus, the groupbox.  How can I do this?  I've tried something like   (this .Parent as ObservableCollection<asdf>).Remove(this );   where asdf is a UserControl but I get a bunch of compiler errors.

Custom Theme for entire Site Collection

I created a theme with custom css for sharepoint 2010 Is it possible for me to use my custom CSS and have it be a selectable theme from each site without me having to modify the master pages of each site that wants to use the theme?

Creating a new root Site Collection using a custom site definition file (ONET.XML)

Using Powershell, I am trying to deploy the our custom solution to SP 2010.  The script is doing the following: Deleting the web application using Remove-SPWebApplication Creating a new web application using New-SPWebApplication Adding and deploying a series of WSP files (one of which has the site definition file in it) using Add-SPSolution and Install-SPSolution Create a root site collection based on the site definition file provided in the WSPs using New-SPSite I get the error "WARNING: Template is not found and is not applied." When I run Get-SPWebTemplate, my site definition does not show up. I saw this: http://social.msdn.microsoft.com/Forums/en/sharepoint2010general/thread/5ea46e07-a4b0-4bab-b698-9b6eeb695607 but I want a solution that does not involve me reloading a DLL, as, I feel there is something else I am forgetting. I have also tried: IISReset Resetting the timer service Cleaning the Cache (as described here: http://support.microsoft.com/kb/939308) Nothing seems to work.  Does anyone have any ideas?

how to create site collection by using custom template through programmatically?

hi all, how we can create site collection by using custom template through programmatically? please give me some suggestions. where we need to save this custom template... thanks in advance..

how to add custom site collection template in central admin site in SharePoint2010?

hi all, how can we add custom template in cendtral admin in sharepoint 2010? In 2007, we can add by using the stsadm tool addtemplate operation....but 2010 tremplate is saved as a solution file not a .stp file...so how we can add this template in central admin site in SharePoint 2010? Please give me some suggestions...... thanks in advance.....

how to create site collection by using custom template through programmatically?

hi all, how we can create site collection by using custom template through programmatically? please give me some suggestions. where we need to save this custom template... thanks in advance..

How to embed jquery library in ASP.NET Custom Server Control

i created custom server control using jquery. i  embeded  jquery library in the control using following code. but it displays object expected error.  has someone done this before ?   //other code    protected override void RenderContents(HtmlTextWriter output) {    output.Write("<div id=\"bckPopup\"></div>"); }   protected void onInit(EventArgs e) { Page.ClientScript.RegisterClientScriptResource(GetType(), "HelpServerControl.Scripts.jquery-1.4.1.min.js");   string javascript = "<script type='text/javascript'> " +   "$(document).ready(function () { " +   "$('#bckPopup').text(\"loaded\"); " + "});</script>" ;   if (!(Page.ClientScript.IsClientScriptBlockRegistered("bhelp" ))) Page.ClientScript.RegisterStartupScript(this.GetType(), "bhelp" , javascript); base .OnInit(e);   }      

How do I get a filtered collection of MembershipUsers from a data store using custom profile propert

A portion of my web.config file:   <profile enabled="true" defaultProvider="AspNetSqlProfileProvider">      <properties>        <add name="FirstName" type="System.String" />        <add name="LastName" type="System.String" />        <add name="Age" type="System.Byte" />        <add name="Weight" type="System.Byte" />        <add name="City" type="System.String" />        <add name="State" type="System.Byte" />        <add name="RelationshipStatus" type="System.Byte" />        <add name="PostalCode" type="System.String" allowAnonymous="true" />        <add name="FavoriteURLs" type="System.Collections.Specialized.StringCollection" allowAnonymous="true" />        <add name="ProfilePhotoFullPath" type="System.S

Dynamic ModalPopupExtender within a Custom server control

Hi folks,   I have this piece of code which paint an ImageButton and show a dynamic ModalPopupExtender (with 2 buttons btnGuardar and btCancel). The issue is neither btGuardar.Click nor btHidden.Click events are raised but ImageButton Click event is raised correctly. Please can you help mee?  protected HtmlGenericControl _divControlContainer = new HtmlGenericControl(); protected ModalPopupExtender _PopupHandler = new ModalPopupExtender(); protected override void CreateChildControls() { Page.Trace.Write("void CreateChildControls()"); _divControlContainer = new HtmlGenericControl("ivContenedor"); Button btHidden = new Button(); btHidden.ID = "hiddenTargetControlForModalPopup"; btHidden.Style.Add(HtmlTextWriterStyle.Display, "none"); btHidden.Click += new EventHandler(event_HiddenTargetModalPopup_Click); //EVENT NOT RISED _divControlContainer.Controls.Add(btHidden); ImageButton ib = new ImageButton(); ib.ID = "btUploadImage"; ib.ImageUrl = "~/Imagenes/UIControlImageViewer/upload.png"; ib.Height = new Unit("16px"); ib.Width = new Unit("16px"); ib.Click += new ImageClickEventHandler(event_UploadFile_Click); //EVENT RAISED CORRECTLY _divControlContainer.Controls.Add(ib);

unable to trace value after postback within Custom Server Control

public class TextBox : AStateManagement, IControl { #region "Variables" #region "Local Variables" protected System.Web.UI.WebControls.WebControl _TextBox = null; protected string _CssClass = string.Empty; protected string _Text = string.Empty; protected bool _Visible = true; protected bool _Enabled = true; protected string _ID = string.Empty; protected bool _IsViewStateLoaded = false; #endregion "Local Variables" #region "Global Variables" #endregion "Global Variables" #endregion "Variable" #region "Constructor" public TextBox() { _TextBox = new System.Web.UI.WebControls.TextBox(); _TextBox.ID = this.UniqueID; } #endregion "Constructor" #region "Events" #endregion "Events" #region "Disposable" #endregion "Disposable" #region "Properties" public override string CssClass { get { return _CssClass; } set { _TextBox.CssClass = _CssClass = value; } } public virtual string Text { get { return _Text; }

Custom server control Books and URLs


Hi all,
      I am new to custom server control. I want to create my own grid like custom server control for my project. Please suggest me some good books and urls.


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend