- LayoutEditorPart Web Server Control
in ASP.NET environment,This article describes you how to work with LayoutEditorPart Web Control.The mechanism of LayoutEditorPart can provide an editor control that enables users to edit several layout-oriented user interface (UI) properties on web page.
The LayoutEditorPart has inherited from the EditorPart class, and is used to edit properties that affect the layout of an associated WebPart or GenericWebPart control. The LayoutEditorPart control that available in an EditorZone control. The Web Parts control set contains the following two features:
- They are helper controls that enable end users to personalize controls on a Web Parts page.
- They are visible only in certain display modes.
Properties of LayoutEditorPart
- Title property - allows the user to gets or sets the title for a layout control.
- Display property -Describes the visiblity ofthe LayoutEditorPart control. The LayoutEditorPart control is always visible when the page is in edit mode,
Methods of LayoutEditorPart
- ApplyChanges- Saves the values from a LayoutEditorPart control to the corresponding properties. return true when saving is succeed, otherwise false.
- SyncChanges-Retrieves the property values from a WebPart control and assigns them to the associated LayoutEditorPart control.
the following code snippets demonstrates how to work with the LayoutEditorPart Control
in .aspx.cs page,
-
protected void Page_Load(object sender, EventArgs e)
{
btn1.Visible = false;
txt1.Visible = false;
BulletedList1.DataBind();
}
protected void btn1_Click(object sender, EventArgs e)
{
LayoutEditorPart1.Title = Server.HtmlEncode(txt1.Text);
}
protected void LayoutEditorPart1_PreRender(object sender, EventArgs e)
{
btn1.Visible = true;
txt1.Visible = true;
}
-
in .aspx page,
-
<%@ Register Src="~/displayModeMenuCS.ascx"
TagPrefix="uc1"
TagName="DisplayModeMenuCS" %>
<html >
<head id="Head1" runat="server">
</head>
<body>
<form id="form2" runat="server">
<asp:SqlDataSource ID="ds1" runat="server"
connectionString="<%$ ConnectionStrings:Con %>"
SelectCommand="Select * From Table1"/>
<asp:WebPartManager ID="wp1" runat="server" />
<uc1:DisplayModeMenuCS id="menu1" runat="server" />
<asp:WebPartZone ID="wz1" runat="server" Width="150"
style="z-index: 100; left: 10px; position: absolute; top: 90px" >
<ZoneTemplate>
<asp:Panel ID="panel1" runat="server" Title="Author List WebPart">
<asp:Label ID="Label1" runat="server"
Text="Author Names"
Font-Bold="true"
Font-Size="120%"/>
<asp:BulletedList ID="BulletedList1" runat="server"
DataSourceID="ds1"
DataTextField="au_lname"
DataValueField="au_id"/>
</asp:Panel>
</ZoneTemplate>
</asp:WebPartZone>
<asp:WebPartZone ID="wz2" runat="server" Width="150"
style="z-index: 101; left: 170px; position: absolute; top: 90px" />
<asp:EditorZone ID="EditorZone1" runat="server"
style="z-index: 102; left: 340px; position: absolute; top: 90px"
Width="170px">
<ZoneTemplate>
<asp:LayoutEditorPart ID="LayoutEditorPart1" runat="server"
Title="My Layout Editor" OnPreRender="LayoutEditorPart1_PreRender" />
</ZoneTemplate>
</asp:EditorZone>
<asp:Button ID="btn1" runat="server" Width="140"
Text="Update EditorPart Title"
style="left: 340px; position: absolute; top: 65px; z-index: 103;"
OnClick="btn1_Click" />
<asp:TextBox ID="txt1" runat="server"
style="z-index: 105; left: 500px; position: absolute; top: 65px" />
</form>
</body>
</html>
-
- Related Links
-
66a70d49-0fdc-41e1-9da1-3490d044b859|0|.0