+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / WebEditors inside RadWindow and callback

WebEditors inside RadWindow and callback

15 posts, 0 answered
  1. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    05 Jun 2009
    Link to this post
    Hi,

    Could you help-us to add one WebEditor like ContentSelector inside one Radwindow and callback some articleID property to one ItextControl for Templates

    Thanks

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    08 Jun 2009
    Link to this post
    Hi Pierre,

    There is a problem with the built in content selector. In this case you should develop a custom one.
    I have prepared a custom selector for you.

    Here is the code below:

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using Telerik.Cms.Web.UI; 
    using System.Web.UI.WebControls; 
    using Telerik.Cms.Engine; 
    using System.Web.UI; 
    using Telerik.Framework.Web; 
     
    /// <summary> 
    /// Summary description for CustomContentSelector 
    /// </summary> 
    ///  
     
    namespace Telerik.Samples 
     
        public class CustomContentSelector : WebUITypeEditor<Guid> 
        { 
            public CustomContentSelector() 
            { 
            } 
            #region Properties 
            public override Guid Value 
            { 
                get 
                { 
                    object o = this.ViewState["itemId"]; 
                    if (o == null
                        return Guid.Empty; 
                    else 
                    { 
     
                        return (Guid)o; 
                    } 
                } 
                set 
                { 
                    this.ViewState["itemId"] = value; 
                } 
            } 
     
            public string TemplatePath 
            { 
                get 
                { 
                    object o = this.ViewState["templatePath"]; 
                    if (o == null
                        return "~/CustomControls/ProvidersListTemplate.ascx"
                    return (string)o; 
                } 
                set 
                { 
                    this.ViewState["templatePath"] = value; 
                } 
            } 
     
            /// <summary> 
            /// Gets or sets the name of the provider. 
            /// </summary> 
            public string ProviderName 
            { 
                get 
                { 
                    return this.providerName; 
                } 
                set 
                { 
                    this.providerName = value; 
                } 
            } 
            #endregion 
            // control references 
            //TODO 
            protected virtual ListControl ProvidersList 
            { 
                get { return this.Controls[0].FindControl("providersList"as ListControl; } 
            } 
            protected virtual GridView ItemsGrid 
            { 
                get { return this.Controls[0].FindControl("itemsGrid"as GridView; } 
            } 
             
            protected override void CreateChildControls() 
            { 
                ContentManager manager1 = new ContentManager(); 
                this.template = ControlUtils.GetTemplate<DefaultSelectorTemplate>(this.TemplatePath); 
                this.template.InstantiateIn(this); 
     
                base.CreateChildControls(); 
                 
                ListControl list = this.ProvidersList; 
                list.AutoPostBack = true
                ICollection<string> provNames = null
                if (TypeContainer != null && base.TypeContainer is IProviderName) 
                    provNames = ((IProviderName)base.TypeContainer).ModuleProviderNames; 
                if (provNames == null
                    provNames = manager1.GetProviders().Keys; 
     
     
                if (provNames.Count != 0) 
                { 
                    foreach (string name in provNames) 
                    { 
                        if (!String.IsNullOrEmpty(name)) 
                        { 
                            ListItem item = new ListItem(name.Replace('_', ' '), name); 
                            if (name == this.providerName) 
                                item.Selected = true
                            list.Items.Add(item); 
                        } 
                    } 
                    this.manager = new ContentManager(list.SelectedValue); 
                    list.SelectedIndexChanged += new EventHandler(list_SelectedIndexChanged); 
                    this.ItemsGrid.RowDataBound += new GridViewRowEventHandler(ItemsGrid_RowDataBound); 
                    this.ItemsGrid.RowCommand += new GridViewCommandEventHandler(ItemsGrid_RowCommand);               
                        this.ItemsGrid.DataSource = manager.GetContent(); 
                        this.ItemsGrid.DataKeyNames = new[] { "ID" }; 
                        this.ItemsGrid.DataBind(); 
                } 
                list.Visible = (list.Items.Count > 1); 
                 
     
            } 
     
            void ItemsGrid_RowDataBound(object sender, GridViewRowEventArgs e) 
            { 
                if (e.Row.RowType == DataControlRowType.DataRow) 
                    if (e.Row.Cells.Count > 1) 
                    { 
                        Label lbl = e.Row.FindControl("label1"as Label; 
                        if (lbl != null
                        { 
                            object obj = ((IContent)e.Row.DataItem).GetMetaData(manager.Provider.DefaultMetaField); 
                            if (obj != null
                            { 
                                lbl.Text = obj.ToString(); 
                            } 
                        } 
                    } 
                //if (e.Row.DataItem != null && ((IContent)e.Row.DataItem).ID == this.itemId) 
                    
            } 
     
            void ItemsGrid_RowCommand(object sender, GridViewCommandEventArgs e) 
            { 
                switch (e.CommandName) 
                { 
                    case "Select"
                        this.ViewState["itemId"] = (Guid)((GridView)sender).DataKeys[Convert.ToInt32(e.CommandArgument)].Value; 
                        OnValueChanged(new ValueChangedEventArgs(this.itemId)); 
                        break
                } 
            } 
     
            void list_SelectedIndexChanged(object sender, EventArgs e) 
            { 
                this.itemId = Guid.Empty; 
                this.providerName = ((ListControl)sender).SelectedValue; 
                this.RecreateChildControls(); 
            } 
            #region Private fields 
            private Guid itemId; 
            private string providerName; 
            private ContentManager manager; 
            private ITemplate template; 
            #endregion 
        } 
     
        public class DefaultSelectorTemplate : ITemplate 
        { 
            public void InstantiateIn(Control container) 
            { 
     
            } 
        } 

    and you need to have the following ControlTemplate

    <asp:DropDownList ID="providersList" runat="server" ></asp:DropDownList> 
     
    <asp:GridView runat="server" ID="itemsGrid" AutoGenerateColumns="false" PageSize="13" GridLines="none" CssClass="listItems"
    <Columns> 
        <asp:CommandField SelectText="Select" ShowSelectButton="true" /> 
        <asp:TemplateField> 
        <ItemTemplate> 
        <asp:Label ID="label1" runat="server"></asp:Label> 
         
        </ItemTemplate> 
        </asp:TemplateField> 
    </Columns> 
    </asp:GridView> 

    Then you can implement the other logic for the RadWindow.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    08 Jun 2009
    Link to this post
    Hi Ivan,

    Many thanks for help this help. You new implementation is working but have same problem that orginal. After get provider and items, you can't select the items. One error are generated on select, simalar as original control. Could you try to fix this complex issue? Regards

    Server Error in '/MyProject' Application.  
    Index was out of range. Must be non-negative and less than the size of the collection.  
    Parameter name: index  
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.  
     
    Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.  
    Parameter name: index  
     
    Source Error:  
     
    Line 207:            {  
    Line 208:                case "Select":  
    Line 209:                    this.ViewState["itemId"] = (Guid)((GridView)sender).DataKeys[Convert.ToInt32(e.CommandArgument)].Value;  
    Line 210:                    OnValueChanged(new ValueChangedEventArgs(this.itemId));  
    Line 211:                    break; 
     
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    08 Jun 2009
    Link to this post
    Hello Pierre,

    I am not able to reproduce this problem with the last release of Sitefinity under which the custom implementation has been developed. However, all items should be selected, most probably you have clicked several times on an item or you have not implemented to control properly  and the item Id cannot be passed.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Eric Wallace
    Eric Wallace avatar
    66 posts
    Registered:
    08 Oct 2009
    29 Apr 2010
    Link to this post
    I'm running into the same problem, and the issue is that the DataKeys collection count is zero in the Row_Command event.

    void ItemsGrid_RowCommand(object sender, GridViewCommandEventArgs e)
            {
                switch (e.CommandName)
                {
                    case "Select":
                        this.ViewState["itemId"] = (Guid)((GridView)sender).DataKeys[Convert.ToInt32(e.CommandArgument)].Value;
                        OnValueChanged(new ValueChangedEventArgs(this.itemId));
                        break;
                }
            }
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    30 Apr 2010
    Link to this post
    Hello Eric Wallace,

    Thank you for joining the conversation.

    Could you make sure that ViewState is enabled on the GridView? Check if EnableViewstate property is set to true.

    Greetings,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Eric Wallace
    Eric Wallace avatar
    66 posts
    Registered:
    08 Oct 2009
    04 May 2010
    Link to this post
    I had the wrong template path specified which was causing the error. Now I am just running up against nothing happening when I click the Select buttonfield.

    Also, this.itemId is not set before calling OnValueChanged(new ValueChangedEventArgs(this.itemId)); in the example

    Would you mind elaborating on "Then you can implement the other logic for the RadWindow."?

    Thanks,
    Eric
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    05 May 2010
    Link to this post
    Hi Eric Wallace,

    Could you please show us a sample of your code? Specifically - how do you subscribe to the event you want to run your logic in?

    Kind regards,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  9. Bruno Michels
    Bruno Michels avatar
    125 posts
    Registered:
    16 Apr 2010
    28 Jun 2010
    Link to this post
    I have the same problem he had...

    Specified argument was out of the range of valid values.
    Parameter name: index
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    How can I set the template path?

    public class NewsSelector : WebUITypeEditor<Guid>
    {
        ...
    }

    I guess it is finding the template, but this.Controls has 0 controls.
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    28 Jun 2010
    Link to this post
    Hi Bruno Michels,

    There is a public string TemplatePath which returns the path to the template that will be used by the custom selector.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Venkat
    Venkat avatar
    105 posts
    Registered:
    20 Nov 2008
    22 Dec 2010
    Link to this post
    Hi Ivan,
    I think I came very close to the solution , but somewhere I missed something.

    I am using article selector to display all blog posts to select .Article selector contains a grid which shows all posts.Selected posts are stored in a list (the Value property.)
    This can be converted into a string with semi colon separated using type converter.
    When I click on the select rad window opens with grid view but there is now submit or cancel button.

    After selection , when I close my rad window , OnClientClose event is firing but

    sender.argument property is returning null or undefined. How can I get the selected post ids from rad window and set my text box with those ids.

    Thanks
    Venkat

    Here is my code:

    Listtype Editor:
    using System;
    using System.Collections;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Collections.Generic;
    namespace Telerik.Samples
    {
        using Cms.Web.UI;
        using Framework.Web;
        using Web.UI;
        using Telerik.Cms.Engine;
        using System.Data;
        /// <summary>
        /// WebEditor control used for editing the items (ListLinks property)
        /// of the links list in user friendly manner
        /// </summary>
        public class ListItemEditor : WebUITypeEditor<List<string>>, IControlPropertyEditor
        {
            #region Properties
            /// <summary>
            /// Gets or sets the Value property - Value property represents the property which TypeEditor
            /// will edit of the parent control which fired the type editor. In our sample, Value property
            /// represents ListLinks property of the LinksList6.ascx user control
            /// </summary>
            public override List<string> Value
            {
                get
                {
                    if (listLinks == null)
                        listLinks = new List<string>();
                    return listLinks;
                }
                set
                {
                    listLinks = value;
                }
            }
            /// <summary>
            /// Gets or sets the path of the Dialog template
            /// </summary>
            public string DialogTemplatePath
            {
                get
                {
                    string value = (string)ViewState["DialogTemplatePath"];
                    return String.IsNullOrEmpty(value) ? "~/UC/TypeEditorTemplate.ascx" : value;
                }
                set
                {
                    ViewState["DialogTemplatePath"] = value;
                }
            }
            /// <summary>
            /// Gets or sets the Dialog template
            /// </summary>
            public ITemplate DialogTemplate
            {
                get
                {
                    dialogTemplate = ControlUtils.GetTemplate<DefaultDialogTemplate>(DialogTemplatePath);
                    return dialogTemplate;
                }
                set
                {
                    dialogTemplate = value;
                }
            }
            /// <summary>
            /// Returns a dictionary with the dependent properties
            /// </summary>
            /// <remarks>
            /// DependentProperties property allows us to modify additional properties
            /// (not just the value of the property which fired TypeEditor) of the control which
            /// has called TypeEditor. In this sample we will modify LinkTarget property in addition
            /// to ListLinks property which is represented through ValueProperty of this control.
            /// </remarks>       
            public IDictionary<string, object> DependentProperties
            {
                get
                {
                    if (dependentProps == null)
                    {
                        dependentProps = new Dictionary<string, object>();
                        //dependentProps.Add("LinkTarget", linkTarget);
                    }
                    return dependentProps;
                }
            }
     
     
            /// <summary>
            /// First time to Bind grid
            /// </summary>
            public bool IsGridLoadedFirstTime
            {
                get
                {
                    if (ViewState["IsGridLoadedFirstTime"] == null)
                        return true;
                   
                    return false;
                }
                set
                {
                    ViewState["IsGridLoadedFirstTime"] = value;
                }
            }
     
            public SortDirection GridViewSortDirection
            {
                get
                {
                    if (ViewState["sortDirection"] == null)
                        ViewState["sortDirection"] = SortDirection.Ascending;
                    return (SortDirection)ViewState["sortDirection"];
                }
                set
                {
                    ViewState["sortDirection"] = value;
                }
            }
     
            public string GridViewSortBy
            {
                get
                {
                    if (ViewState["GridViewSortBy"] == null)
                        ViewState["GridViewSortBy"] = "Title";
                    return (string)ViewState["GridViewSortBy"];
                }
                set
                {
                    ViewState["GridViewSortBy"] = value;
                }
            }
     
            #endregion
            #region Methods
            /// <summary>
            /// Overriden. Cancels the rendering of a beginning HTML tag for the control.
            /// </summary>
            /// <param name="writer">The HtmlTextWriter object used to render the markup.</param>
            public override void RenderBeginTag(HtmlTextWriter writer)
            {
                // Do not render begin tag
            }
            /// <summary>
            /// Overriden. Cancels the rendering of an ending HTML tag for the control.
            /// </summary>
            /// <param name="writer">The HtmlTextWriter object used to render the markup.</param>
            public override void RenderEndTag(HtmlTextWriter writer)
            {
                // Do not render end tag
            }
            /// <summary>
            /// Overrides the base method and registers ControlDesignerBase control as one whose control state
            /// must be persisted.
            /// </summary>
            /// <param name="e"></param>
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                if (Page != null)
                    Page.RegisterRequiresControlState(this);
            }
            /// <summary>
            /// Restores control state information from a previous page request that was saved by the SaveControlState
            /// method.
            /// </summary>
            /// <param name="savedState">Represents the control state to be restored.</param>
            protected override void LoadControlState(object savedState)
            {
                if (savedState != null)
                {
                    object[] state = (object[])savedState;
                    listLinks = (List<string>)state[0];
                
                }
            }
            /// <summary>
            /// Saves server control state changes.
            /// </summary>
            /// <returns></returns>
            protected override object SaveControlState()
            {
                return new object[] { 
       listLinks
      };
            }
            /// <summary>
            /// Overriden. Called to populate the child control hierarchy. This is the main
            /// method to render the control's markup, since it is a CompositeControl and contains
            /// child controls.
            /// </summary>
            protected override void CreateChildControls()
            {
                // initialize the container and template
                dialogContainer = new Container(this);
                DialogTemplate.InstantiateIn(dialogContainer);
                 
                dialogContainer.FilterByDropDownList.AutoPostBack = true;
                dialogContainer.FilterByDropDownList.SelectedIndexChanged += new EventHandler(FilterByDropDownList_SelectedIndexChanged);
     
                dialogContainer.FilterItemsDropDownList.AutoPostBack = true;
                dialogContainer.FilterItemsDropDownList.SelectedIndexChanged += new EventHandler(FilterItemsDropDownList_SelectedIndexChanged);
     
     
                dialogContainer.BlogPostsGrid.RowDataBound += new GridViewRowEventHandler(BlogPostsGrid_RowDataBound);
                dialogContainer.BlogPostsGrid.Sorting+=new GridViewSortEventHandler(BlogPostsGrid_Sorting);
                dialogContainer.BlogPostsGrid.PageIndexChanging += new GridViewPageEventHandler(BlogPostsGrid_PageIndexChanging);
                dialogContainer.BlogPostsGrid.RowCommand += new GridViewCommandEventHandler(BlogPostsGrid_RowCommand);
                
                Controls.Add(dialogContainer);
                if (IsGridLoadedFirstTime)
                {
                    BindFilterItemsDropDownList();
                    IList selectedBlogs = contentManager.GetContent(0, 0, "Publication_Date " + sortExpression);
                    BindBlogPosts(selectedBlogs);
                    IsGridLoadedFirstTime = false;
                }
            }
     
            void BlogPostsGrid_RowCommand(object sender, GridViewCommandEventArgs e)
            {
                string select = "select";
                string unselect = "unselect";
                LinkButton sourceBtn = e.CommandSource as LinkButton;
     
                if (e.CommandName == select)
                {
                    if (Value != null && !Value.Contains((string)e.CommandArgument))
                    {
                        Value.Add((string)e.CommandArgument);
                        sourceBtn.CommandName = unselect;
                        sourceBtn.Text = unselect;
                        OnValueChanged(new ValueChangedEventArgs(this.Value));
                    }
                }
                else
                {
                    if (Value != null && Value.Contains((string)e.CommandArgument))
                    {
                        Value.Remove((string)e.CommandArgument);
                        sourceBtn.CommandName = select;
                        sourceBtn.Text = select;
                        OnValueChanged(new ValueChangedEventArgs(this.Value));
                    }
                }
            }
     
            void BlogPostsGrid_PageIndexChanging(object sender, GridViewPageEventArgs e)
            {
                GetBlogPostsAndBind(GridViewSortBy,ConvertSortDirectionToSql(GridViewSortDirection));
                dialogContainer.BlogPostsGrid.PageIndex = e.NewPageIndex;
                dialogContainer.BlogPostsGrid.DataBind();
            }
     
            void BlogPostsGrid_Sorting(object sender, GridViewSortEventArgs e)
            {
                if (GridViewSortBy != e.SortExpression)
                {
                    GridViewSortDirection = SortDirection.Ascending;
                    GridViewSortBy = e.SortExpression;
                }
                else
                {
                    if (GridViewSortDirection == SortDirection.Ascending)
                    {
                        GridViewSortDirection = SortDirection.Descending;
                    }
                    else
                    {
                        GridViewSortDirection = SortDirection.Ascending;
                    }
                }
                GetBlogPostsAndBind(GridViewSortBy,ConvertSortDirectionToSql(GridViewSortDirection));
            }
     
                   
            #endregion
            #region Private methods
     
     
            private string ConvertSortDirectionToSql(SortDirection sortDirection)
            {
                string newSortDirection = String.Empty;
     
                switch (sortDirection)
                {
                    case SortDirection.Ascending:
                        newSortDirection = " ASC";
                        break;
     
                    case SortDirection.Descending:
                        newSortDirection = " DESC";
                        break;
                }
     
                return newSortDirection;
            }
     
            private void BindBlogPosts(IList selectedBlogs)
            {
                dialogContainer.BlogPostsGrid.DataSource = selectedBlogs;
                dialogContainer.BlogPostsGrid.DataBind();
            }
     
            private void BindFilterItemsDropDownList()
            {
                if (dialogContainer.FilterByDropDownList.SelectedValue == "All")
                {
                    dialogContainer.FilterItemsDropDownList.Visible = false;
                    dialogContainer.SelectTagOrCategoryLiteral.Visible = false;
                    return;
                }
                dialogContainer.FilterItemsDropDownList.Visible = true;
                dialogContainer.SelectTagOrCategoryLiteral.Visible = true;
     
                if (dialogContainer.FilterByDropDownList.SelectedValue == "Category")
                {
                    dialogContainer.SelectTagOrCategoryLiteral.Text = "Select a Category:";
                    // create a list of all categories
                    IList listOfCategories = contentManager.GetCategories();
                    if (listOfCategories.Count > 0)
                    {
                        dialogContainer.FilterItemsDropDownList.Items.Clear();
                        foreach (Telerik.Cms.Engine.ICategory catItem in listOfCategories)
                        {
                            ListItem item = new ListItem(catItem.CategoryName, catItem.ID.ToString());
                            dialogContainer.FilterItemsDropDownList.Items.Add(item);
                        }
                         
                    }
                }
                else
                {
                    dialogContainer.SelectTagOrCategoryLiteral.Text = "Select a Tag:";
                    // create a list of all categories
                    IList listOfTags = contentManager.GetTags();
                    if (listOfTags.Count > 0)
                    {
                        dialogContainer.FilterItemsDropDownList.Items.Clear();
                        foreach (Telerik.Cms.Engine.ITag tagItem in listOfTags)
                        {
                            ListItem item = new ListItem(tagItem.TagName, tagItem.ID.ToString());
                            dialogContainer.FilterItemsDropDownList.Items.Add(item);
                        }
                   }
                }
                dialogContainer.FilterItemsDropDownList.Items.Insert(0,new ListItem("All","All"));
                dialogContainer.FilterItemsDropDownList.SelectedIndex = 0;
                if (!IsGridLoadedFirstTime)
                {
                    GetBlogPostsAndBind(GridViewSortBy,sortExpression);
                }
            }
     
     
            private void GetBlogPostsAndBind(string sortBy,string sortExpression)
            {
                if (dialogContainer.FilterByDropDownList.SelectedValue == "All" || (dialogContainer.FilterItemsDropDownList.SelectedItem != null && dialogContainer.FilterItemsDropDownList.SelectedItem.Text == "All"))
                {
                    IList selectedBlogs = contentManager.GetContent(0, 0, sortBy + sortExpression);
                    BindBlogPosts(selectedBlogs);
                    return;
                }
     
                if (dialogContainer.FilterByDropDownList.SelectedValue == "Category")
                {
                    List<IMetaSearchInfo> publicationFilters = new List<IMetaSearchInfo>();
                    MetaSearchInfo filter1 = new MetaSearchInfo(MetaValueTypes.ShortText, "Category", dialogContainer.FilterItemsDropDownList.SelectedItem.Text, SearchCondition.Like);
                    publicationFilters.Add(filter1);
                    IList selectedBlogs = contentManager.GetContent(sortBy + sortExpression, publicationFilters.ToArray());
                    BindBlogPosts(selectedBlogs);
                }
                else
                {
                    IList selectedBlogs = contentManager.GetContent(0, 0, sortBy + sortExpression, dialogContainer.FilterItemsDropDownList.SelectedItem.Text);
                    BindBlogPosts(selectedBlogs);
                }
     
            }
     
            #endregion
            #region Event handlers
            void FilterItemsDropDownList_SelectedIndexChanged(object sender, EventArgs e)
            {
                GetBlogPostsAndBind(GridViewSortBy,sortExpression);
            }
     
            void BlogPostsGrid_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    IContent content = e.Row.DataItem as IContent;
                    if (content != null)
                    {
                       string title= (string)content.GetMetaData("Title");
                       Literal litTitle = e.Row.FindControl("litTitle") as Literal;
     
                       Literal litDate = e.Row.FindControl("litDate") as Literal;
                       litDate.Text = string.Format("{0:dd/MM/yy}",content.GetMetaData("Publication_Date"));
     
                       LinkButton lnkBtnSelect = e.Row.FindControl("lnkBtnSelect") as LinkButton;
     
                       if (listLinks !=null && listLinks.Contains(content.ID.ToString()))
                       {
                           lnkBtnSelect.Text = unselect;
                           lnkBtnSelect.CommandName = unselect;
                       }
                       else
                       {
                           lnkBtnSelect.Text = select;
                           lnkBtnSelect.CommandName = select;
                       }
                       litTitle.Text = title;
                     }
                }
     
            }
     
             
     
          
     
            private void FilterByDropDownList_SelectedIndexChanged(object sender, EventArgs e)
            {
                 BindFilterItemsDropDownList();
            }
            #endregion
            #region Private Propeties
            private List<string> listLinks;
            private string sortExpression = " ASC";
            //private string linkTarget;
            private ITemplate dialogTemplate;
            private Container dialogContainer;
            private Dictionary<string, object> dependentProps;
            private bool isGridBinded = false;
            string select = "select";
            string unselect = "unselect";
            Telerik.Cms.Engine.ContentManager contentManager = new Telerik.Cms.Engine.ContentManager("Blogs");
            #endregion
            #region Default Templates
            /// <summary>
            /// Class which defines the template for this control, in case template has not been
            /// defined through an external file or through inline declaration
            /// </summary>
            private class DefaultDialogTemplate : ITemplate
            {
                public void InstantiateIn(Control container)
                {
                    throw new Exception("Default template for LinksListItemEditor has not been implemented.");
                }
            }
            #endregion
            #region Containers
            /// <summary>
            /// Class which provides easy, strongly-typed access to the child controls defined in a template
            /// regardless of their position in the child control hierarchy
            /// </summary>
            private class Container : GenericContainer<ListItemEditor>
            {
                public Container(ListItemEditor owner)
                    : base(owner)
                {
                }
                 
     
                public GridView BlogPostsGrid
                {
                    get
                    {
                        if (blogPostsGrid == null)
                            blogPostsGrid = FindRequiredControl<GridView>("postListGrid");
                        return blogPostsGrid;
                    }
                }
     
                public DropDownList FilterByDropDownList
                {
                    get
                    {
                        if (filterByDropDownList == null)
                            filterByDropDownList = FindRequiredControl<DropDownList>("ddlFilterBy");
                        return filterByDropDownList;
                    }
                }
     
                public DropDownList FilterItemsDropDownList
                {
                    get
                    {
                        if (filterItemsDropDownList == null)
                            filterItemsDropDownList = FindRequiredControl<DropDownList>("ddlItems");
                        return filterItemsDropDownList;
                    }
                }
     
                public Literal SelectTagOrCategoryLiteral
                {
                    get
                    {
                        if (selectTagOrCategoryLiteral == null)
                            selectTagOrCategoryLiteral = FindRequiredControl<Literal>("litSelectTagOrCategory");
                        return selectTagOrCategoryLiteral;
                    }
                }
     
                private Repeater blogPostsRepeater;
                private GridView blogPostsGrid;
                private DropDownList filterByDropDownList;
                private DropDownList filterItemsDropDownList;
                private Literal selectTagOrCategoryLiteral;
            }
            #endregion
     
     
      
        }
    }

    Selector code:
    <asp:Label ID="lblMainArticles" runat="server" Text="Choose Articles *" AssociatedControlID="tbMainArticles"></asp:Label>
                                    <asp:TextBox ID="tbMainArticles" runat="server" />
                                    <sfLib:ButtonSelector WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/ArticleSelector.aspx"
                                 ItemTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/Dialogs/ButtonSelector.ascx" AssociatedControls="tbMainArticles"
                                  runat="server" cssclass="pickerWrapper" ButtonText="Select" />

    ArticleSelector.aspx

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ArticleSelector.aspx.cs" Inherits="Sitefinity_UserControls_Dialogs_ArticleSelector" %>
    <%@ Register Src="~/UC/ArticleSelector.ascx" TagPrefix="co" TagName="ArticleSelector" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <head runat="server">
        <title>Article Selector</title>
        <link type="text/css" rel="stylesheet" href="~/Sitefinity/UserControls/Dialogs/CustomDialogs.css" />
        <link type="text/css" rel="stylesheet" href="~/Sitefinity/UserControls/Dialogs/RadControlsSkins.css" />
        <link type="text/css" rel="stylesheet" href="~/sitefinity/admin/Themes/Default/CustomDialogs.css" />
        <link type="text/css" rel="stylesheet" href="~/sitefinity/admin/Themes/Default/RadControlsSkins.css" />
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
         <asp:ScriptManager id="ScriptManager" runat="server"/>
        <co:ArticleSelector ID="articleSelector" runat="server" />
        </div>
        </form>
    </body>
    </html>



    ArticleSelector.ascx

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ArticleSelector.ascx.cs" Inherits="UC_ArticleSelector" %>
    <%@ Register Src="~/UC/TypeEditorTemplate.ascx" TagPrefix="co" TagName="EditorTemplate" %>
    <asp:PlaceHolder ID="phArticleSelector" runat="server" ></asp:PlaceHolder>

    ArticleSelector.ascx.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Samples;
     
    public partial class UC_ArticleSelector : System.Web.UI.UserControl
    {
     
        ListItemEditor listItemEditor = new ListItemEditor();
     
        protected void Page_Load(object sender, EventArgs e)
        {
            phArticleSelector.Controls.Add(listItemEditor);
        }
    }



  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    22 Dec 2010
    Link to this post
    Hi,

    You can take a look at this demo which shows how to return values from RadWindow.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Venkat
    Venkat avatar
    105 posts
    Registered:
    20 Nov 2008
    23 Dec 2010
    Link to this post
    Thank you Ivan.
    It worked for me.

    -Regards
    Venkat
  14. Conrad Ehinger
    Conrad Ehinger avatar
    59 posts
    Registered:
    22 Sep 2009
    20 Jan 2011
    Link to this post
    Hello,

    I am trying to use the same kind of selector (select blog posts) and was trying to implement your code. However, it seems you did not provide your dialog template. Could you please share that? It would help out very much.

    Thank you!

    Chris
  15. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    20 Jan 2011
    Link to this post
    Hello,

    You can use the template provided in one of the initial replies.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
15 posts, 0 answered