Passing string to MVC controller as a widget property

Posted by Community Admin on 04-Aug-2018 17:16

Passing string to MVC controller as a widget property

All Replies

Posted by Community Admin on 12-Dec-2017 00:00

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

 

 

Posted by Community Admin on 13-Dec-2017 00:00

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.

This thread is closed