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

Forums / Developing with Sitefinity / Programatically Change the View of Module

Programatically Change the View of Module

8 posts, 0 answered
  1. Montane Hamilton
    Montane Hamilton avatar
    10 posts
    Registered:
    25 Apr 2004
    20 Apr 2010
    Link to this post
    Developing a pluggable module. Trying to switch the view on a button click.

    public void AddNewClientButton_Click(object sender, ImageClickEventArgs e)
    {
       //Change view to wizard.
       NavigateHostCommand<ClientCreateWizard>();
    }

    I can't seem to find the right reference for the "NavigateHostCommand", I've downloaded the books sample module and it too has the correct reference missing?
  2. Montane Hamilton
    Montane Hamilton avatar
    10 posts
    Registered:
    25 Apr 2004
    21 Apr 2010
    Link to this post
    I'm actually guessing the "view" that is inheriting from the SimpleControl class won't work. It looks like I need to re-architect this and change to use ViewModeControl?
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    21 Apr 2010
    Link to this post
    Hello Montane Hamilton,

    Here is a blog posts ( How to navigate among views topic) that explain everything about navigation between views.

    Kind 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.
  4. Montane Hamilton
    Montane Hamilton avatar
    10 posts
    Registered:
    25 Apr 2004
    22 Apr 2010
    Link to this post
    Thanks for that link. So I've got the view setup and am getting a route in the querystring. When navigating to the url with the route though I just get the same view instead of navigating to the requested view? Where should I start in trying to debug why this would happen?

    FYI this example is with the module being hosted inside a page on the site, not in the admin.

    /Clients.aspx?route=ClientsController.ClientsCreateWizard

    So I have two views, ClientsListView which is the default view, thoguh I'm nto sure how the default view is defined.

    The second view is the ClientsCreateWizard

    I navigate to /Clients.aspx and on that page is the a link to /Clients.aspx?route=ClientsController.ClientsCreateWizard

    When I click that link I just get the same ClientsListView

    From the Controller (ControlPanel)

    protected override void CreateViews()
    {
        AddView<ClientsListView>();
        AddView<ClientsCreateWizard>();
    }

    From the ClientListView

    protected override void InitializeControls(Control controlContainer)
    {
        base.InitializeControls(controlContainer);
        //Route is set here.
        AddNewClientButton.NavigateUrl = CreateRootViewCommand(typeof (ClientsController), typeof (ClientsCreateWizard));
        SearchButton.Click += SearchButton_Click;
        //Pull Information from the Data Manager (Provider)
        Info info = (Info)_manager.GetInfo();
    }

  5. Montane Hamilton
    Montane Hamilton avatar
    10 posts
    Registered:
    25 Apr 2004
    22 Apr 2010
    Link to this post
    OK so it appears I've been going down a dead end. So what I was trying to do is build a set of views that would be navigated around in the front end. At this time the module does not have admin but we want to package all the front end controls in a package by using a module.

    It appears that you cannot just drop the module into a page and usign the routes to have that page change the shown view of the module. Can Telerik let me know if I understand this right and fill in anything I might not be getting.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    27 Apr 2010
    Link to this post
    Hello Montane Hamilton,

    The modules cannot be dropped on a page. You could drop user or custom controls on a  page. The host commands can be used only for the backend modules. You may find this article useful - Sitefinity Architecture

    Sincerely yours,
    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. Montane Hamilton
    Montane Hamilton avatar
    10 posts
    Registered:
    25 Apr 2004
    29 Apr 2010
    Link to this post
    Right, I do understand I cannot drop a module on a page.... but what I'd like to do is drop the front end onto a page. Like the back end where the "control panel" can consist of several views that allow you to break logic up logically in "views", we would like to do the same on the front end.

    Right now I have two controls, one to view and manage "clients" and one to add new "clients". On the control that manages is a link to add a "client". Right now I've had to make the traget of that url a page and expose that as a setting so they can set the value to the page that will be hosting the "add client" control. This leads to a brittle solution.

    Using user controls just seems crazy as we will need a 1 to 1 of control to page...

    Using a custom control would allow everything in one control but I have no experience building one and am wondering if I can implement the separation of logic into "views" within a custom control. We then lose the separation of markup from code also.

    Thoughts?
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    29 Apr 2010
    Link to this post
    Hello Montane Hamilton,

    You need a custom control that supports operations as Insert/Update/Delete. You could use one of our controls to manage your data as shown in the blog posts linked below

    Insert Update and Delete with RadGrid.
    Insert Update and Delete with RadScheduler

    You could create your own control to perform the same operations, but you need to start from scratch.

    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