Search code examples
c#asp.netweb-controls

Programmatically use a copy of existing on-page customized control


On one page i use a web-control (do not pay attention that this is not standart webcontrol, there's no difference for that question):

<telerik:RadComboBox runat="server" id="rcbAssocClient" Width="400px"
    MarkFirstMatch="true" EnableLoadOnDemand="true"
    HighlightTemplatedItems="true"
    onitemsrequested="rcbAssocClient_ItemsRequested">
    <HeaderTemplate>
    <ul>
         <li class="col1">FirstName</li>
         <li class="col2">LastName</li>
         <li class="col3">BirthDate</li>
    </ul>
   </HeaderTemplate>
   <ItemTemplate>
        <ul>
             <li class="col1">
                  <%# DataBinder.Eval(Container.DataItem, "FirstName") %></li>
             <li class="col2">
                  <%# DataBinder.Eval(Container.DataItem, "LastName") %></li>
             <li class="col3">
                  <%# DataBinder.Eval(Container.DataItem, "BirthDate", "{0:d/M/yyyy}")%></li>
        </ul>
   </ItemTemplate>
</telerik:RadComboBox>

How can i save this template to create the same control on another page programmatically like that:

MyRadComboBox cb = new MyRadComboBox();

without rewriting item template and so on.

Thanks in advance for Your time and help.


Solution

  • You can create your template in a separated file ascx and load with method LoadTemplate

    I hope to be helpful