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

Forums / Developing with Sitefinity / Dynamic Hyperlink Template

Dynamic Hyperlink Template

8 posts, 0 answered
  1. Ricardo Marcelino
    Ricardo Marcelino avatar
    15 posts
    Registered:
    04 Nov 2009
    30 Mar 2010
    Link to this post
    Hello Telerik Team!

    I would like some guidance on something.

    I want the client to be able to drag a Dynamic Hyperlink Control and have the possibility to change NavigateUrl and the Text displayed. It isn't possible to set a template or change the way the control is being rendered, so that i could have a <div> inside the link and inside the <div>, the text that was set?

    Should i go another way? I need to have html/asp.net content inside the Dynamic Hyperlink Control in this scenario.
    I was thinking of a custom control with a Hyperlink control and a Text control, and then a custom edit dialog with two fields (URL with dialog to navigate trough the website's pages and select one; Text to display). If this is the way to go, can you point me in the right direction of developing this edit dialog?

    Thanks in advance,
    Ricardo Marcelino
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    30 Mar 2010
    Link to this post
    Hi Ricardo Marcelino,

    NavigateUrl and Text are public properties so you could set them through the control designer. The control does not have template. The DynamicHyperLink inherits from WebControl. You can override WebControl.AddAttributesToRender Method and add HTML attributes and styles.

    You could also create a custom control that inherits from SimpleControl class. You could override LayoutTemplatePath and set your custom template that the control will use.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Ricardo Marcelino
    Ricardo Marcelino avatar
    15 posts
    Registered:
    04 Nov 2009
    31 Mar 2010
    Link to this post
    This is the base of what i need to be displayed:

    <asp:HyperLink runat="server" NavigateUrl="SELECT PAGE AND INSERT">
        <div class="sideMenuOption">
            <%--<img alt="" src="something.jpeg" />--%>
            <div class="sideMenuElement">
                <label>INSERT TEXT</label>
            </div>
        </div>
    </asp:HyperLink>

    Can you be more specific? Should i build a .ascx or a .dll? I still want to be able to define a Edit Dialog that i can use to define the SELECT PAGE AND INSERT and andINSERT TEXT. What should i look at to proceed?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    31 Mar 2010
    Link to this post
    Hello Ricardo Marcelino,

    You need to create a class library, not an user control. "NavigateUrl and Text are public properties so you could set them through the control designer."

    Regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Ricardo Marcelino
    Ricardo Marcelino avatar
    15 posts
    Registered:
    04 Nov 2009
    01 Apr 2010
    Link to this post
    Hello,

    So, my custom control inherits from WebControl. Then i override the AddAttributesToRender method and place all the html there. Then i would have a control designer and get/set those public properties. This is the logic?

    I don't think, ever, that html code should be implemented through a class (except on particular cases, of course). Each time i would want/need to change something, i would have to build the control again.

    I should create a custom control that inherits from SimpleControl class, then override and define a template (this way i can edit with more freedom) and then apply a control designer to it. This was your second advice right?

    Sorry for being stubborn, but this is a more acessible way to make changes when needed.
    Thank you,
    Ricardo Marcelino

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    01 Apr 2010
    Link to this post
    Hello Ricardo Marcelino,

    You could inherit from Telerik.Cms.Engine.WebControls.DynamicHyperLink, so that you will use the buil-in logic as well. The override AddAttributesToRender(). As written in the previous posts DynamicHyperLink does not use template. You could implement a custom one by inheriting from ITemplate interface. If you inherit from SimpleControl you  can override LayoutTemplatePath and set a custom template to the control, but you will lost all other logic.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Ricardo Marcelino
    Ricardo Marcelino avatar
    15 posts
    Registered:
    04 Nov 2009
    06 Apr 2010
    Link to this post
    What if i don't inherit from other controls?

    Could I create a User Control (.ascx) where i have only HTML markup (the same code i posted but instead of <asp:Hyperlink>, I write <a>) where i would implement, on the Edit dialog, the two dialogs i need (select image from library and select page), which are dialogs that already exist, and a TextBox?

    Then, on my HTML markup i would have Eval to write what i want, where i want.

    Could you help me with some links or samples? I'm kinda lost on the logic behind it all, to implement it, and it would be a great and functional addition to the dynamics of the site the client as asked for!

    Thanks in advance,
    Ricardo Marcelino
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    07 Apr 2010
    Link to this post
    Hi Ricardo Marcelino,

    You can implement custom WebEditors that will allow you to select an image and page. You can gather more information about how to create custom WebEditor at Creating a custom WebUITypeEditor

    Regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
8 posts, 0 answered