Deliver superior customer experiences with an AI-driven platform for creating and deploying cognitive chatbots
Deliver Awesome UI with the most complete toolboxes for .NET, Web and Mobile development
Automate UI, load and performance testing for web, desktop and mobile
A complete cloud platform for an app or your entire digital business
Detect and predict anomalies by automating machine learning to achieve higher asset uptime and maximized yield
Automate decision processes with a no-code business rules engine
Optimize data integration with high-performance connectivity
Connect to any cloud or on-premises data source using a standard interface
Build engaging multi-channel web and digital experiences with intuitive web content management
Personalize and optimize the customer experience across digital touchpoints
Build, protect and deploy apps across any platform and mobile device
Rapidly develop, manage and deploy business apps, delivered as SaaS in the cloud
The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
[This post is part of the developer's manual preview published on this blog. You can find temporary TOC here.]
[This post has been updated after the feedback.]
*** DEFINITION ***
*** END DEFINITION ***
If you wish, you can download the module from here and examine its code as we explain different approaches for navigating between Views.
Let us imagine that on the ProductsListView we have a HyperLink with title “Add new product”. When user clicks on the button, we would like Sitefinity to load ProductsNewView View. We can achieve that with a following line of code.
SAMPLE 1: CreateHostViewCommand returns proper command for a specified View
CreateHostViewCommand is a generic method in this case and as its generic argument it receives the type of View for which the Command should be generated.
*** WARNING ***
CreateHostViewCommand and its overloads can be used only for generating commands to the views in the current hierarcy or route, as we will call it. For example, you can use CreateHostViewCommand in ProductsListView to generate commands for ProductNewView or ProductEditView, but not to generate command for CustomerListView.
*** END WARNING ***
SAMPLE 2: Redirecting user to a new view after certain operation has been completed.
*** NOTE ***
You can see that we are putting an optional argument in the method call here, namely the parameter that we want to pass to the ProductPreviewView. We will explore this feature in more detail in the topics to come.
*** END NOTE ***
We have already mentioned that you can use CreateHostViewCommand and NavigateHostViewCommand only when the view for which you are creating command or to which you are navigating are in the same hierarchy or route.
Sometimes, however, there is a need to jump between hierarchies. Let’s suppose that in our CustomersListView we have a link which can open the product that customer has bought. Obviously, since we have our ProductPreviewView ready and implemented, ideally we’d like to create command for that view and pass the product id as parameter. To achieve this we can use CreateRootViewCommand function as follows:
NavigateRootViewCommand is an equivalent of NavigateHostViewCommand but serves the same purpose as CreateRootViewCommand, namely enables you to navigate (jump) between hierarchies or routes.
The signature of the CreateRootViewCommand is different in so much that it takes any number of View types (in proper hierarchical order!) and generates a command to that View even if you are in a different hierarchy.
*** SAMPLE PROJECT ***
You can download a sample module that demonstrates the concepts that we’ve discussed in this article. To install the module, you will need Sitefinity 3.6. Once you have downloaded the files, paste the App_Code and ViewTemplates folders at the root of your website and run the website.
*** END SAMPLE PROJECT ***
We have plans to enhance the API for User Control based Views in the future versions and bring their functionality as close as possible to those of Custom Control based Views.
To illustrate these samples, we have prepared a sample project where Views are based on ViewModeUserControl base classes or in other words, Views are created from User Controls.
You can download the sample module with User Control based Views from here. To install the module, you will need Sitefinity 3.6. Once you have downloaded the files paste the App_Code and Views folders at the root of your website and run the website.
*** END SAMPLE PROJECT ***
View all posts from The Progress Guys on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Copyright © 2018 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.