Created
November 10, 2016 13:51
-
-
Save MaheshHika/b1c4005aa5fabb9ae487440d4adf3ac4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ToolboxItemAttribute(false)] | |
public class CustomWebPart : Microsoft.SharePoint.WebPartPages.WebPart | |
{ | |
// Visual Studio might automatically update this path when you change the Visual Web Part project item. | |
private const string _ascxPath = @"~/_CONTROLTEMPLATES/15/test/CustomControl.ascx"; | |
private const string RelativeFolderCss = "../ReferencedFiles/css"; | |
private const string RelativeFolderJs = "..ReferencedFiles/js"; | |
protected override void CreateChildControls() | |
{ | |
IModuleBinder moduleBinder = new ModuleBinder(); | |
List<List<HtmlGenericControl>> consolidatedControls = new List<List<HtmlGenericControl>>(); | |
List<HtmlGenericControl> metaTags = new List<HtmlGenericControl>(); | |
metaTags = moduleBinder.ControlDefinitionMetaTags(); | |
consolidatedControls.Add(metaTags); | |
List<HtmlGenericControl> javascriptControls = new List<HtmlGenericControl>(); | |
javascriptControls = moduleBinder.ControlDefinitionJavascripts(RelativeFolderJs); | |
consolidatedControls.Add(javascriptControls); | |
List<HtmlGenericControl> cssControls = new List<HtmlGenericControl>(); | |
cssControls = moduleBinder.ControlDefinitionCss(RelativeFolderCss); | |
consolidatedControls.Add(cssControls); | |
foreach (List<HtmlGenericControl> genericControls in consolidatedControls) | |
{ | |
foreach (HtmlGenericControl htmlControls in genericControls) | |
{ | |
this.Controls.Add(htmlControls); | |
} | |
} | |
Control control = Page.LoadControl(_ascxPath); | |
Controls.Add(control); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment