// </snippet3> // <snippet4> protected void Button3_Click(object sender, EventArgs e) { Label1.Text = String.Empty; WebPartZoneBase[] zoneArray = new WebPartZoneBase[mgr.Zones.Count]; mgr.Zones.CopyTo(zoneArray, 0); Label1.Text = zoneArray[2].ID; Label1.Text += ", " + zoneArray[1].ID; Label1.Text += ", " + zoneArray[0].ID; }
public WebPartZoneBaseInstance(ObjectInstance prototype, WebPartZoneBase webPartZoneBase) : this(prototype) { if (webPartZoneBase == null) { throw new ArgumentNullException("webPartZoneBase"); } m_webPartZoneBase = webPartZoneBase; }
/// <summary> /// 把自定义控件加入页面 /// </summary> /// <param name="url">自定义控件的地址</param> /// <param name="id">控件ID,由于是动态生成的,所以页面上要有一个该View的ID,只要各个ID不同就可以了</param> /// <param name="title">webpart左上角的标题</param> /// <param name="zone">放在哪个zone中,webpartzone1或webpartzone2,1大,2小</param> private void AddIFrameWebPart(string url, string id, string title, WebPartZoneBase zone) { IFrameWebPart webPart = new IFrameWebPart(); webPart.Url = string.Format("../../{0}", url); webPart.ID = id; webPart.Title = title; _WebPartManager.AddWebPart(webPart, zone, 0); AddEmptyPage(); }
/// <summary> /// 把自定义控件加入页面 /// </summary> /// <param name="url">自定义控件的地址</param> /// <param name="id">控件ID,由于是动态生成的,所以页面上要有一个该View的ID,只要各个ID不同就可以了</param> /// <param name="title">webpart左上角的标题</param> /// <param name="zone">放在哪个zone中,webpartzone1或webpartzone2,1大,2小</param> private void AddWebPart(string url, string id, string title, WebPartZoneBase zone) { Control webUserControl = LoadControl("../../../Views/" + url); webUserControl.ID = id; GenericWebPart webPart = _WebPartManager.CreateWebPart(webUserControl); webPart.Title = title; //webPart.TitleIconImageUrl = "../../../Pages/image/icon09.jpg"; _WebPartManager.AddWebPart(webPart, zone, 0); AddEmptyPage(); }
internal static string GetZoneDesc(WebPartZoneBase zone) { SystemWebPart [] parts = new SystemWebPart [zone.WebParts.Count]; zone.WebParts.CopyTo(parts, 0); Array.Sort <SystemWebPart> (parts, delegate(SystemWebPart one, SystemWebPart two) { int c = one.DisplayTitle.Length.CompareTo(two.DisplayTitle.Length); return((c == 0) ? one.DisplayTitle.CompareTo(two.DisplayTitle) : c); }); return(string.Join(" • ", Array.ConvertAll <SystemWebPart, string> (parts, (wp) => { return wp.DisplayTitle; }))); }
private void WebPartManager_WebPartAdding(object sender, WebPartAddingEventArgs e) { WebPartZoneBase zone = e.Zone; if (e.ZoneIndex < zone.WebParts.Count) { WebPart part = zone.WebParts[e.ZoneIndex]; if (part != null && part is ISymbolWebPart && !part.IsStatic) { base.WebPartManager.DeleteWebPart(part); } } }
private void ImportPortletInternal(string importXml, out string errorMessage, bool feedback, string zoneId) { if (importXml == null) { throw new ArgumentNullException("importXml"); } var wpm = WebPartManager.GetCurrentWebPartManager(Page); using (var sr = new StringReader(importXml)) { using (XmlTextReader xmlReader = new XmlTextReader(sr)) { var webPart = wpm.ImportWebPart(xmlReader, out errorMessage); if (String.IsNullOrEmpty(errorMessage)) { WebPartZoneBase selectedWebPartZone = null; selectedWebPartZone = String.IsNullOrEmpty(zoneId) ? GetSelectedZoneInstance() : wpm.Zones[zoneId]; if (selectedWebPartZone != null) { wpm.AddWebPart(webPart, selectedWebPartZone, selectedWebPartZone.WebParts.Count); if (feedback) { UIControls.DisplayFeedback( String.Format("Portlet has been imported successfully. <br />")); } } else { UIControls.DisplayErrorMessage( String.Format("There is no '{0}' zone on the current page. <br />", UIControls.ImportZoneList.SelectedValue)); } } else { UIControls.DisplayErrorMessage(errorMessage); } } } }
public void Swap(string firstPart, string firstRow, string firstCell, string firstContainer, string secondPart, string secondRow, string secondCell, string secondContainer) { WebPart webPart = base.WebPartManager.WebParts[firstPart]; if (null != webPart) { if (webPart.Zone is TableZone) { TableZone sourceZone = webPart.Zone as TableZone; this.Move(firstPart, firstRow, firstCell, firstContainer, secondPart, secondRow, secondCell, secondContainer); sourceZone.Move(secondPart, secondRow, secondCell, secondContainer, firstPart, firstRow, firstCell, firstContainer); } else { WebPart targetPart = base.WebParts[secondPart]; WebPartZoneBase sourceZone2 = webPart.Zone; base.WebPartManager.MoveWebPart(webPart, this, targetPart.ZoneIndex); base.WebPartManager.MoveWebPart(targetPart, sourceZone2, webPart.ZoneIndex); } } }
public void RaiseCallbackEvent(string eventArgument) { try { string[] eventArg = eventArgument.Split(new string[1] { "#;" }, StringSplitOptions.RemoveEmptyEntries); List <WebPartGalleryItem> webparts = Sources.Where(n => n.Id == eventArg[0]).Select(n => n).ToList(); SPListItem item = SPContext.Current.ListItem; SPFile currentFile = item.File; if (item != null && item != null) { if (currentFile != null && currentFile.Exists) { if (currentFile.CheckOutType == SPFile.SPCheckOutType.None && currentFile.RequiresCheckout) { currentFile.CheckOut(); } } } if (webparts.Count > 0) { foreach (WebPartGalleryItem galleryItem in webparts) { WebPartZoneBase zone = WebPartManager.Zones[eventArg[1]]; //base.waitScreenText = string.Format("Adding {0} in {1} zone.", item.Title, zone.DisplayTitle); galleryItem.Source.AddItemToPage(zone, 0, galleryItem, galleryItem.Id); } //SPContext.Current.ListItem.Update(); } } catch (Exception ex) { result = ex; } }
/// <summary> /// Renders the specified <paramref name="zone"/> with a div, instead of the standard table. /// </summary> /// <param name="writer">The <see cref="HtmlTextWriter"/> to use to render the specific output.</param> /// <param name="zone">The <see cref="WebPartZone"/> to render contents for.</param> private static void RenderWithDiv(HtmlTextWriter writer, WebPartZoneBase zone) { // render zone begin tag writer.AddAttribute(HtmlTextWriterAttribute.Id, zone.ID); if (!String.IsNullOrEmpty(zone.CssClass)) { writer.AddAttribute(HtmlTextWriterAttribute.Class, zone.CssClass); } writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSitePartZone-" + zone.LayoutOrientation); writer.RenderBeginTag(HtmlTextWriterTag.Div); // render web parts within a div for (int i = 0; i < zone.WebParts.Count; i++) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSitePart"); writer.AddAttribute("orientation", zone.LayoutOrientation.ToString(), false); writer.AddAttribute(HtmlTextWriterAttribute.Name, "MSOZoneCell", false); string related = "WebPart" + GetQualifier(zone.WebParts[i]); writer.AddAttribute("relatedwebpart", related, false); if (!zone.WebParts[i].AllowZoneChange) { writer.AddAttribute("allowZoneChange", "0", false); } writer.RenderBeginTag(HtmlTextWriterTag.Div); try { zone.WebParts[i].RenderControl(writer); } catch (Exception) { } writer.RenderEndTag(); } // render zone end tag writer.RenderEndTag(); }
public void CopyTo(WebPartZoneBase[] array, int index) { }
// Methods public bool Contains(WebPartZoneBase value) { }
public SNWebPartChrome(WebPartZoneBase zone, WebPartManager manager) : base(zone, manager) { }
public virtual void MoveWebPart(WebPart webPart, WebPartZoneBase zone, int zoneIndex) { }
public MyWebPartChrome(WebPartZoneBase aZone, WebPartManager aManager) : base(aZone, aManager) { theZone = aZone; theManager = aManager; }
public WebPartEditableDesignerRegion(WebPartZoneBase zone, TemplateDefinition templateDefinition) : base(templateDefinition) { this._zone = zone; }
public int IndexOf(WebPartZoneBase value) { }
// Methods public bool Contains(WebPartZoneBase value) { }
public void RaisePostBackEvent(string eventArgument) { SPContext.Current.Web.AllowUnsafeUpdates = true; try { string[] eventArg = eventArgument.Split(new string[1] { "#;" }, StringSplitOptions.RemoveEmptyEntries); List <WebPartGalleryItem> webparts = Sources.Where(n => n.Id == eventArg[0]).Select(n => n).ToList(); SPListItem item = SPContext.Current.ListItem; SPFile currentFile = item.File; if (item != null && item != null) { if (currentFile != null && currentFile.Exists) { if (currentFile.CheckOutType == SPFile.SPCheckOutType.None && currentFile.RequiresCheckout) { currentFile.CheckOut(); } } } string wpid = StorageKeyToID(eventArg[0]); if (this.WebPartManager.WebParts[wpid] != null) { wpid = null; } if (webparts.Count > 0) { WebPartZoneBase zone = WebPartManager.Zones[eventArg[1]]; foreach (WebPartGalleryItem galleryItem in webparts) { galleryItem.Source.AddItemToPage(zone, 0, galleryItem, wpid);//, galleryItem.Id); } if (wpid != null) { if (this.WebPartManager.WebParts[wpid] != null) { System.Web.UI.WebControls.WebParts.WebPart wp = this.WebPartManager.WebParts[wpid]; //this.WebPartManager.MoveWebPart(wp, zone, 0); //this.WebPartManager.AddWebPart(wp) this.WebPartManager.SaveChanges(this.WebPartManager.GetStorageKey(wp)); } } } } catch (Exception ex) { result = ex; } SPContext.Current.Web.AllowUnsafeUpdates = false; this.RefreshPageState(); HtmlMeta pragma = new HtmlMeta(); pragma.HttpEquiv = "Pragma"; pragma.Content = "no-cache"; Page.Header.Controls.Add(pragma); HtmlMeta expires = new HtmlMeta(); expires.HttpEquiv = "Expires"; expires.Content = "-1"; Page.Header.Controls.Add(expires); HtmlMeta store = new HtmlMeta(); store.HttpEquiv = "Cache-Control"; store.Content = "no-store, no-cache, must-revalidate"; Page.Header.Controls.Add(store); HtmlMeta post = new HtmlMeta(); post.HttpEquiv = "Cache-Control"; post.Content = "post-check=0, pre-check=0"; Page.Header.Controls.Add(post); }
public int IndexOf(WebPartZoneBase value) { }
// Methods public WebPart AddWebPart(WebPart webPart, WebPartZoneBase zone, int zoneIndex) { }
public virtual void MoveWebPart(WebPart webPart, WebPartZoneBase zone, int zoneIndex) { }
public VerbLink(WebPartZoneBase zone, string arg) { this._zone = zone; this._arg = arg; }
// Constructors public WebPartMovingEventArgs(WebPart webPart, WebPartZoneBase zone, int zoneIndex) { }
// Methods public WebPart AddWebPart(WebPart webPart, WebPartZoneBase zone, int zoneIndex) { }
public DesignerWebPartChrome(WebPartZoneBase zone) : base(zone, null) { }
// Constructors public WebPartChrome(WebPartZoneBase zone, WebPartManager manager) { }
// Constructors public WebPartMovingEventArgs(WebPart webPart, WebPartZoneBase zone, int zoneIndex) { }
// Constructors public WebPartChrome(WebPartZoneBase zone, WebPartManager manager) { }