only My site

Monday, October 29, 2012

Dynamic Content Editor Webpart

We can assign the Content link to a content editor webpart dynamically using contentlink property. Also we can create the html content dynamically and assign to a Content Editor Web part dynamically using Content property.

string siteURL = default(string);

try{
siteURL =
SPContext.Current.Web.Url;ContentEditorWebpart1.ContentLink = siteURL +
"/ChairmanMessage.html";
XmlDocument xmlDoc = new XmlDocument();XmlElement xmlElement = xmlDoc.CreateElement(
"EditorContent1");xmlElement.InnerText =
"<HTML><iframe id=ifrm width=100% height=345 src='" + "http://google.com" + "' width='Size' height='Size' marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=1 scrolling=no></iframe></HTML>";ContentEditorWebpart2.Content = xmlElement;
}

catch (Exception exp){

   throw exp;}

No comments: