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

Forums / General Discussions / Dynamic Property changing for usercontrol

Dynamic Property changing for usercontrol

4 posts, 0 answered
  1. MARI
    MARI avatar
    17 posts
    Registered:
    31 Aug 2011
    31 Aug 2011
    Link to this post
    Hi,

    i want to create the dropdown control dynamically for usercontrol properties and assigned all news to the dropdown list.
    if i am select the value of the dropdown its show the  particular news item in my usercontrol.


    public class NewsSelector : WebUITypeEditor<string>
    {
        private DropDownList NewsDDL = null;
        private string _Value = null;
    public NewsSelector()
    {
    //
    // TODO: Add constructor logic here
    //
    }
        public override string Value
        {
            get { return _Value; }
            set { _Value = value; }
        }
        protected override void CreateChildControls()
        {
            Controls.Clear();
            Controls.Add(new LiteralControl("Select Language: "));
           NewsDDL = new DropDownList();
           NewsDDL .Style.Add("Width", "350px");
            NewsDDL.SelectedIndexChanged += new System.EventHandler(NewsDDL_SelectIndexChanged);




            DataTable dtNews = DBLib.ExecuteSQLReturnDataTable("Usp_GetAllNews");
            if (dtNews .Rows.Count > 0)
            {
                  NewsDDL.DataSource = dtLanguage;
                 NewsDDL.DataTextField = "News";
                 NewsDDL.DataValueField = "NewsId";
                 NewsDDL.DataBind();
            }


            //NewsDDL.Items.Insert(0, new ListItem("Select", "0"));
            Controls.Add(NewsDDL);


            if (NewsDDL.Items.Count > 0)
                Value = NewsDDL.SelectedItem.Value;
        }


        void NewsDDL_SelectIndexChanged(object sender, System.EventArgs e)
        {
            Value =NewsDDL.SelectedValue;


        }
    }


    its working in sitefinity 3.7 but i need in 4.2 plz give solution for that.here  WebUITypeEditor<string>  didnt work.
  2. Lubomir Velkov
    Lubomir Velkov avatar
    688 posts
    Registered:
    03 Nov 2014
    02 Sep 2011
    Link to this post
    Hi Mari,

    Sitefinity 4.x API model is very different from 3.7. Instead of WebUITypeEditor<string> you should use SimpleView. Please check the following blog posts that outline how to create a custom widget for Sitefinity 4.x

    http://www.sitefinity.com/blogs/joshmorales/posts/11-09-01/anatomy_of_a_sitefinity_4_widget.aspx

    http://www.sitefinity.com/blogs/ivan/posts/11-01-18/implementing_sitefinity_widgets_and_designers_how_to_implement_facebook_like_button.aspx

    Greetings,
    Lubomir Velkov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. MARI
    MARI avatar
    17 posts
    Registered:
    31 Aug 2011
    05 Sep 2011
    Link to this post
    Thanks for kindly help.

    in this case used the textbox value to bind,(in jquery)
    but i want dropdown list for bind

    i used like this way ,
    Type.registerNamespace("sitefinity42.Widgets.HelloWorld");


    sitefinity42.Widgets.HelloWorldDesigner = function (element) {
        sitefinity42.Widgets.HelloWorldDesigner.initializeBase(this, [element]);
    }


    sitefinity42.Widgets.HelloWorldDesigner.prototype = {
        initialize: function () {
            sitefinity42.Widgets.HelloWorldDesigner.callBaseMethod(this, 'initialize');
        },
        dispose: function () {
            sitefinity42.Widgets.HelloWorldDesigner.callBaseMethod(this, 'dispose');
        },
        refreshUI: function () {
            var controlData = this._propertyEditor.get_control();


            // bind widget properites to designer
            jQuery("#txtName").val(controlData.Name);
           // jQuery("#DropDownList1 option:selected").Text(controlData.Name2);




        },
        applyChanges: function () {


            var controlData = this._propertyEditor.get_control();


            // bind designer properties back to widget
            controlData.Name = jQuery("#txtName").val();
            //controlData.Name2 = jQuery("#DropDownList1 option:selected").Text();


        }
    }


    sitefinity42.Widgets.HelloWorldDesigner.registerClass('sitefinity42.Widgets.HelloWorldDesigner', Telerik.Sitefinity.Web.UI.ControlDesign.ControlDesignerBase);
    if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();



    but its not helped,

    plz help me out from that.

    thanks and regards,
    Mari
  4. Lubomir Velkov
    Lubomir Velkov avatar
    688 posts
    Registered:
    03 Nov 2014
    08 Sep 2011
    Link to this post
    Hi Mari,

    Could you send us the whole code that you have - the .cs designer, any .ascx template and the Javascript. Having this piece of Javascript code out of context isn't helping much.

    Regards,
    Lubomir Velkov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

4 posts, 0 answered