Category Archives: EditorZone

EditorZone

[RESOLVED]Get htmlgeneric control in javascript

Hello all,

in c#

HtmlGenericControl div = new HtmlGenericControl();
div.ID = "div";

this.Title = "Search Settings";
div= new System.Web.UI.HtmlControls.HtmlGenericControl("div");
div.ID = "divChkList";

i want to get div id in javascript or jquery

var objDLL = document.getElementById("ctl00_MSOTlPn_EditorZone_g_cb887242_84af_4d1a_ad1a_c2e960f5b379_editorPart1_divChkList");

//it working fine:because it return [object htmldivelement] but problem is that it’s it change in another machine.

document.getElementById("<%=divChkList.ClientID%>")  //not working: this code returns null

var objDLL = $(‘[id$="<%=divChkList.ClientID%>"]‘);//not working : this code returns [object Object]

if (objDLL.style.display == "block")
objDLL.style.display = "none";

what’s wrong this code please help me….

 

Hi,

Try this-

$("div[id*=divChkList]")

rabindra_lal

var objDLL = $(‘[id$="<%=divChkList.ClientID%>"]‘);//not working : this code returns [object Object]

It returns object, that means control is found.

now if you are using jquery then change your condition like this,

if (objDLL.css('display') == 'block')

   objDLL.hide(); // or objDLL.css('display','none');

Hi,

You got the control in js by ..

var objDLL = $(‘[id$="<%=divChkList.ClientID%>"]‘);

now try, somethng like this , to get the exact element.

put condition or some assgmnt here .......  $('#objDLL').children().css('display', 'block');

the codebehind is inherited by the aspx code generated. to get the dynamic div id in aspx code, you need to define a public or protected varable the aspx code can access.

    protected HtmlGenericControl divChkList;

    …

    div= new System.Web.UI.HtmlControls.HtmlGenericControl("div");
    divChkList.ID = "divChkList";

<div>alternately, in the aspx code you can do a recursive walk of the control tree looking for the control with the id "divChkList". </div> <div></div>

[RESOLVED]Custom Property in WebPart Editor Zone

I have webparts which display the content. Using Webpart Editor zone I need to select display style whether it is Grid or List or Rolling (from Dropdownlist). How can i add custom property in Webpart Editor Zone. I’m newbie to this.

I have googled about this but got nothing.

Hi,

   Greetings!

vigneshkumar957_Solution

I have webparts which display the content. Using Webpart Editor zone I need to select display style whether it is Grid or List or Rolling (from Dropdownlist). How can i add custom property in Webpart Editor Zone

You can create a Custom Webpart Editor Zone according to your need.

If you want to create a custom EditorZone zone to gain greater control over the rendering of the editing UI, you can inherit directly from the
EditorZoneBase class, as long as you do not need to provide zone template support for page developers to add
EditorPart controls to your zone declaratively. In such a case, you would add all
EditorPart controls to a zone programmatically. If you want to provide zone template support, you should inherit from the
EditorZone class.

For code examples refer to the following code:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.editorzone(v=vs.110).aspx

http://www.codeguru.com/csharp/.net/net_asp/webforms/article.php/c12487/Writing-Custom-Editors-for-WebParts.htm

Hope it helps!

Best Regards!

I didn’t get any replies here, but I was able to figure out a way to do some of these. In the end I decided to overirde the EditorPart class. The ApplyChanges() and SyncChanges() methods essentially just persist the changes from the page to the personalization
blob and vice-versa. It’s a matter of rendering some controls on the page, and mapping the values to the properties of the web part in these methods.

Like 

Imports Microsoft.VisualBasic
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Data
Imports FormsUtilities

Namespace CustomEditorZone

    Public Class CustomEditor : Inherits EditorPart

        Public Sub New()
            Me.Title = "Change Display Style"
        End Sub 'New

        Private PartPropertyValue As DropDownList

        Protected Overrides Sub CreateChildControls()
            Controls.Clear()
            PartPropertyValue = New DropDownList()
            PartPropertyValue.AppendDataBoundItems = True
            PartPropertyValue.Items.Add("")
            PopulateControl(PartPropertyValue)
            Me.Controls.Add(PartPropertyValue)
        End Sub 'CreateChildControls

        Public Overrides Function ApplyChanges() As Boolean

            EnsureChildControls()
            Dim MyWebPart As GenericWebPart = DirectCast(WebPartToEdit, GenericWebPart)
            Dim MyControl As CustomWebPart.WebPartBaseConsumer = DirectCast(MyWebPart.ChildControl, CustomWebPart.WebPartBaseConsumer)
            MyControl.DisplayStyle = PartPropertyValue.SelectedItem.Text
            Return True

        End Function 'ApplyChanges

        Public Overrides Sub SyncChanges()
            Try
                EnsureChildControls()
                Dim MyWebPart As GenericWebPart = DirectCast(WebPartToEdit, GenericWebPart)
                Dim MyControl As CustomWebPart.WebPartBaseConsumer = DirectCast(MyWebPart.ChildControl, CustomWebPart.WebPartBaseConsumer)
                Dim CurrentDisplay As String = MyControl.DisplayStyle

                For Each Item As ListItem In PartPropertyValue.Items
                    If Item.Text = CurrentDisplay Then
                        Item.Selected = True
                        Exit For
                    End If
                Next
            Catch ex As Exception

            End Try

        End Sub 'SyncChanges

        Protected Overrides Sub RenderContents(ByVal writer As HtmlTextWriter)
            Try
                writer.Write("Display Style :")
                writer.Write("&nbsp;")
                Me.PartPropertyValue.RenderControl(writer)
            Catch ex As Exception

            End Try

        End Sub 'RenderContents

        Private Sub PopulateControl(ByRef PartPropertyValue As DropDownList)

            PartPropertyValue.Items.Add("Grid")
            PartPropertyValue.Items.Add("List")
            PartPropertyValue.Items.Add("Rolling")
        End Sub

    End Class 'CustomEditor
End Namespace