Search code examples
asp.netdotnetnuke-7

Why HyperLink control don't get url?


I use a HyperLink control in my page

<asp:HyperLink runat="server" ID="btn_add_Task" Text="Create New Task" CssClass="dnnPrimaryAction"></asp:HyperLink>

In code behinde set it url

 protected void On_Load(object sender, EventArgs e)
        {
            base.OnLoad(e);

            btn_add_Task.NavigateUrl = ModuleContext.EditUrl("Edit");
        }

But When build and run, it don't have any url in properties.


Solution

  • In order for the EditUrl("Edit") to work, you need to make sure you have a module view with the controlkey that matches "Edit". Here is what that looks like in your .dnn manifest file for installing the module:

    <moduleControl>
        <controlKey>Edit</controlKey>
        <controlSrc>DesktopModules/MyModule/Edit.ascx</controlSrc>
        <controlType>Edit</controlType>
        ...
    </moduleControl>
    

    And it should look like this in Host > Extensions > [Edit you Extension] > Module Definitions:

    enter image description here

    Notice I have a control with "Edit" key that maps to my Edit.ascx view