Pages

Saturday, August 16, 2014

How To: Load SharePoint web part User Control Inside another SharePoint web part without C# Coding

simple way to Load SharePoint web part User Control Inside another  SharePoint web part without C# Coding is done by :

  1. registering the user control
    <%@ Register src="webPartUC.ascx" tagname="webPartUC" tagprefix="uc" %>

  2. loading the user control <uc:webPartUC ID="webPartUC1" runat="server" />
if you wanted to pass webpart properties.. all you have to do is to specify the values as follows:
<uc:webPartUC ID="webPartUC1" LabelText="TEXT" runat="server" />

if you wanted to pass webpart properties from within a DataList Control Items .. all you have to do is to specify the values as follows making sure to add the below line inside the DataList:

 <asp:DataList ID="usersDL" runat="server" Width="100%" >
   <ItemTemplate>
         <uc:webPartUC ID="webPartUC1"
              LabelText=<%# Eval("userName")%> runat="server" />

    </ItemTemplate>
 </asp:DataList>


Thats it :)