More in this section

Forums / Developing with Sitefinity / Question on "Creating a simple control designers" tutorial

Question on "Creating a simple control designers" tutorial

20 posts, 0 answered
  1. Ancuta Me
    Ancuta Me avatar
    43 posts
    Registered:
    26 Apr 2010
    19 May 2011
    Link to this post
    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.

  2. Ancuta Me
    Ancuta Me avatar
    43 posts
    Registered:
    26 Apr 2010
    19 May 2011
    Link to this post
    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.
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    23 May 2011
    Link to this post
    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
  4. Ancuta Me
    Ancuta Me avatar
    43 posts
    Registered:
    26 Apr 2010
    24 May 2011
    Link to this post
    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.
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    24 May 2011
    Link to this post
    Hi Ancuta Me,

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

    http://msdn.microsoft.com/en-us/library/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
  6. FlR
    FlR avatar
    49 posts
    Registered:
    05 Oct 2010
    24 May 2011
    Link to this post
    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!
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    24 May 2011
    Link to this post
    Hello FlR,

    You need to use Virtual Path Provider settings

    http://www.sitefinity.com/blogs/slavoingilizov/posts/11-04-18/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
  8. FlR
    FlR avatar
    49 posts
    Registered:
    05 Oct 2010
    24 May 2011
    Link to this post
    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!
  9. FlR
    FlR avatar
    49 posts
    Registered:
    05 Oct 2010
    24 May 2011
    Link to this post
    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!
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    27 May 2011
    Link to this post
    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
  11. FlR
    FlR avatar
    49 posts
    Registered:
    05 Oct 2010
    27 May 2011
    Link to this post
    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
  12. FlR
    FlR avatar
    49 posts
    Registered:
    05 Oct 2010
    27 May 2011
    Link to this post
    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.
  13. FlR
    FlR avatar
    49 posts
    Registered:
    05 Oct 2010
    30 May 2011
    Link to this post
    Hi,

    Can you please provide some directions on this.

    Thank you!
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    30 May 2011
    Link to this post
    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
  15. FlR
    FlR avatar
    49 posts
    Registered:
    05 Oct 2010
    30 May 2011
    Link to this post
    Hi Ivan,

    Thank you! It's exactly what I was looking for.
  16. FlR
    FlR avatar
    49 posts
    Registered:
    05 Oct 2010
    30 May 2011
    Link to this post
    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.
  17. FlR
    FlR avatar
    49 posts
    Registered:
    05 Oct 2010
    31 May 2011
    Link to this post
    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)
  18. FlR
    FlR avatar
    49 posts
    Registered:
    05 Oct 2010
    31 May 2011
    Link to this post
    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!
  19. FlR
    FlR avatar
    49 posts
    Registered:
    05 Oct 2010
    02 Jun 2011
    Link to this post
    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?
  20. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    06 Jun 2011
    Link to this post
    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
20 posts, 0 answered