Question on "Creating a simple control designers"

Posted by Community Admin on 04-Aug-2018 13:24

Question on "Creating a simple control designers" tutorial

All Replies

Posted by Community Admin on 19-May-2011 00:00

Hi,

I have followed this tutorial hoping to learn how to setup fields in the edit mode of a control that would have an effect over the content displayed by that control.

But I got this result (please see attached) and I lost the ability to edit/delete any another control on the page.
I did not enhance the code in tutorial in any way, is this suppose to happen?

Thank you.

Posted by Community Admin on 19-May-2011 00:00

Update: I managed to resolve my previous problem and added a text field to be displayed in the designer.
It does not appear; and even after choosing to open the designer in simple mode (this.DesignerMode = ControlDesignerModes.Simple;), I get both buttons (attached).

Looking at the console I see this error: "Sys is not defined" but I'm not sure what it means.

Posted by Community Admin on 23-May-2011 00:00

Hi Ancuta Me,

There is an issue with the client component of your control. I prepared and attached a sample for you.

Regards,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 24-May-2011 00:00

Hi Ivan ,

You were right, there was a problem and I managed to move past it.
I even got the popup to show when clicking edit in the admin interface.

After updating the SDK and moving my project I get the attached error (I assume it has to do with the update).
Can you tell me how to get rid of it?

Thank you.

Posted by Community Admin on 24-May-2011 00:00

Hi Ancuta Me,

Please enable service tracer that will allow you to see the actual error

msdn.microsoft.com/.../ms732023.aspx


Best wishes,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 24-May-2011 00:00

Hi Ivan,

I've tried to use the sample code but I'm getting an error.

If I'm using without changing it I'm getting a normal error.
Cannot find template "~/SfSamples/Telerik.Sitefinity.Samples.Resources.SimpleViewCustomTemplate.ascx".

I've updated the tempalte path to private const string layoutTemplatePath = "~/Telerik.Sitefinity.Samples.Resources.SimpleViewCustomDesigner.ascx";
and then I got the error: Cannot find template "~/Telerik.Sitefinity.Samples.Resources.SimpleViewCustomTemplate.ascx".

Last thing I tried was to set the path to: private const string layoutTemplatePath = "Telerik.Sitefinity.Samples.Resources.SimpleViewCustomDesigner.ascx";
but I'm getting this error:The relative virtual path 'Telerik.Sitefinity.Samples.Resources.SimpleViewCustomTemplate.ascx' is not allowed here.

Please let mw know what the path should be.

Thank you!

Posted by Community Admin on 24-May-2011 00:00

Hello FlR,

You need to use Virtual Path Provider settings

www.sitefinity.com/.../taking_advantage_of_the_virtual_path_provider_in_sitefinity_4_1.aspx

You just need to add the proper mappings through the configuration.

All the best,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 24-May-2011 00:00

Hi Ivan,

It worked. Thank you for your support. Two last questions I have:

1. How to a handle the Save event (Save button) so I can go and save the information from SimpleViewCustomDesigner.ascx (let's say the textbox sample) in the database and displaying it in SimpleViewCustomTemplate.ascx (by taken it from database again - previously saved)

2. I want to add more controls on a page. The info for each of them will be saved in the database but I need also the placeholder id where the controls has been drag&drop so on front side I would know where to display and what info to display.

How can I have access to the placeholder Id of the control I drag&drop when I'm handling the Save event?

Thank you!

Posted by Community Admin on 24-May-2011 00:00

Another question Ivan would be how can I pass a value to the designer usercontrol (I want to pass the current page id)

Thank you!

Posted by Community Admin on 27-May-2011 00:00

Hello FlR,

1. There is applyChanges event that is triggered when you perform "Save" in the control designer

2. The ControlData has a property PlaceHolder that you can use to identify the placeholder.

Regards,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 27-May-2011 00:00

Hi Ivan,

I've just tried your sugestion but doesn't seem to work:

applyChanges: function ()
        var data = this.get_controlData();
        console.log(data.PlaceHolder); // ERROR! get_PlaceHolder is not defined
        console.log(this.get_PlaceHolder()); // ERROR! get_PlaceHolder is not defined
        console.log(data.get_PlaceHolder()); // ERROR! get_PlaceHolder is not defined

Posted by Community Admin on 27-May-2011 00:00

I've looked over the entire documentation but didn't find anything yet. I think this is an important part in wroking with widgets - having multiple widgets of the same type in the same page.

Posted by Community Admin on 30-May-2011 00:00

Hi,

Can you please provide some directions on this.

Thank you!

Posted by Community Admin on 30-May-2011 00:00

Hi FlR,

Please add the following code to the control designer which will allow you to get the PlaceHolder

var pm = PageManager.GetManager();
ControlData control = pm.GetControls<PageDraftControl>().Where(c => c.Id == this.ControlId).SingleOrDefault();
if (control == null)
   
          control = pm.GetControls<TemplateDraftControl>().Where(c => c.Id == this.ControlId).SingleOrDefault();
   
var placeholder = control.PlaceHolder;



this.get_controlData(); does not return ControlData object.

All the best,
Ivan Dimitrov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 30-May-2011 00:00

Hi Ivan,

Thank you! It's exactly what I was looking for.

Posted by Community Admin on 30-May-2011 00:00

I'm sorry but I still have one question. Palceholder has the same value for all the widget instances (of the same type) i'm using, but this now is not a problem as I'm using the ControlId property from designer to identify them.

Tha question is how can I access in the view (not designer - so bascailly in the page) this property so I would know what info to take from database - for what control instance.

Posted by Community Admin on 31-May-2011 00:00

Hi Ivan,

I investigated more on this. Shouln't be in control view (not designer) a similar property with from ControlId  deisgner.

I think that somehow the deisnger and view should share a specific id or the view should know what is the control deisnger id (at runtime - render)

Posted by Community Admin on 31-May-2011 00:00

Hi Ivan,

Can you please provide more details as I'm sure that we are very closer and we have many widgets in our project that the admin cand add multiple times on the same page.

Thank you!

Posted by Community Admin on 02-Jun-2011 00:00

Looking at what is rendered I've seen that the client id (on the front side has the form ContentPlaceHolderXXX_C00XXX) eg: ContentPlaceHolder1_C005
<span id="ContentPlaceHolder1_C005">

How can I get this informatio in both the *.cs files: Designer view and simple view?

Posted by Community Admin on 06-Jun-2011 00:00

Hello FlR,

You can expose a public property in the simple view and pass the value that is returned by the designer

var placeholder = control.PlaceHolder;

Regards,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed