More in this section
Forums / Developing with Sitefinity / Passing string to MVC controller as a widget property

Passing string to MVC controller as a widget property

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Richard
    Richard avatar
    49 posts
    Registered:
    13 Jul 2010
    12 Dec 2017
    Link to this post

    Hello

    Previously, I have created .ascx controls that I have managed to tweak allowing me to  pass values from the backend of Sitefinity so they can be used in the code itself e.g.:

    public partial class ComplianceReviewForm : System.Web.UI.UserControl
    {
     
        public string Source { get; set; }
     
        protected void Page_Load(object sender, EventArgs e)
        {

     

    Is there any way to do something similar through MVC?

     

    EDIT: I can seein the default designer that gets created, there is a"Message" example. Effectively, I need to find out the value of this Message control in the MVC controller when it has been changed/updated. Any ideas?

    EDIT II: *sigh* Well in debug mode the designer javascript throws a null reference here anyway :

     

    /* Called when the designer window gets opened and here is place to "bind" your designer to the control properties */
    refreshUI: function () {
        var controlData = this._propertyEditor.get_control().Settings; /* JavaScript clone of your control - all the control properties will be properties of the controlData too */
     
        /* RefreshUI Message */
        jQuery(this.get_message()).val(controlData.Message);
    },
     
    /* Called when the "Save" button is clicked. Here you can transfer the settings from the designer to the control */
    applyChanges: function () {
        var controlData = this._propertyEditor.get_control().Settings;
     
        /* ApplyChanges Message */
        controlData.Message = jQuery(this.get_message()).val();
    },

     

    Rich

     

     

  2. Richard
    Richard avatar
    49 posts
    Registered:
    13 Jul 2010
    13 Dec 2017
    Link to this post
    Ok, I have managed to sort this out myself now. For those who may across this, I highly recommend downloading Sitefininty Thunder, adding a Test MVC widget with designer and look closely at how the example Message property is used.
2 posts, 0 answered