I am using the ASP.net MVC 5 to build the web application.
It's little more complicated than the simple MVC example I googled. Not so sure what I've done is the right way to do.
A user is able to select the Region or an item ID: {number} on the left hand in the Menu 1. The menu is populated as a multi-level menu which means there are two levels of this menu, Region and ID.
Each level decides which controller to call. For example, When Region 1 id clicked, RegionsController will be invoked, and render a view for the content.
There is a Menu 2 on the right hand, it's a menu according to which level clicked, so it could be different menu items depending on whether Region or ID were clicked.
Menu 2 is the functional menu, such as Map, Record, ... For example, Map is a menuitem in Menu2 correspoding to Region Level.
Record is a menuitem in Menu 2 corresponding to ID Level.
The layout is showing as below, including two menus (partial view) and a content.
Scenario:
User clicks on Region 1, call the Region controller to render the view on the right. Menu2 is populated according to the Region. A user is able to click any menu items on Menu2 to render the content
When a user clicked on Region 1, call control action to handle /Region/Index/1 to render the view. I will save the Id = 1 to both the cookie and session in order to use when the Menu 2 menuitem1 or menuitem2 had clicked. So the content is decided by Menu 1 and Menu2.
User clicks on ID:009, call the ID controller to render the view on the right. Menu2 is populated according to the Region. A user is able to click any menu items on Menu2 to render the content
Same as 1. When a user clicked on Region 1, call control action to handle /ID/Index/008 to render the view. I will save the Id = 008 to both the cookie and TempData in order to use when the Menu 2 menuitem1 or menuitem2 had clicked. So the content is decided by Menu 1 and Menu2.
Questions:
If I want to see the Region 1 and Map, I need to save which item (Menu1 item) was clicked. So I can render the content when the menuitem# clicked on the Menu2. The truth is every controller needs to get which Id in Menu 1 was clicked.
Save click item
SessionManager.SaveItem(id, this.HttpContext);
Get click item
SessionManager.GetItem(this.HttpContext);
It is too annoying to do this in every controller. Is there a better way?
Menu1 decides which Menu2 menuitems displays. So I have to keep track of which Menu 2 menuitems shall be display. In the IDController Index action, I need to render the partial view with "Record" menuitem. On the contrary, in the MapController, I need to render the partial veiw with "Map" menuitem.
How could I improve this kind of MVC architecture?
Related
I want to add record with one button on form and sub form. it should remain on current record when cancel or not click button.Product Detail
iNVOICE NO
New Products://i.stack.imgur.com/NYbiL.png
Invoice Form
Go to design tab
Click and drag the button icon into the main form
A wizard should pop up, follow the wizard by
Picking Record operations(to the left),Add new record(to the right)
Click next(at bottom)
Check Text
Click next(at bottom)
Click finish(at bottom)
The images attached depicts the steps.
I have an mvc app where I pass a list to a view. In a most click, I want to be able to render the next item in the last but am having trouble figuring out how to do that efficiently. My approach originally was to use an index i but I realized that one the page is rendered, accessing my model last at i will always leaf to the same result since that item in the list is rendered on page load and can't just be accessed dynamically. Any insight to an approach for this problem?
The model can't be accessed as it's only used on the server side.
There are a few ways of solving the problem, you can use Knockout.js or similar client side view model components, once the user click on the button just render then next item from the knockout model.
Or use AJAX to retrieve the next value from the back end and then render it to the screen.
Or generate the whole screen and just hide all items from the user and then display them once the user clicks the button
I've seen in Joomla documentation the way to detect if you are in Frontpage while creating a template in Joomla 2.5. This is the code:
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
echo 'This is the front page';
}
?>
This works when you are at home page (or clicking on Home menu), but I have an slider in home page, and I link in the slider to an article which is not in any menu item in the application. When I load this article the code above returns as I were at frontpage. I guess that if I doesn't click on any menu item, $menu->getActive() doesn't change.
Any suggestion?
Thanks in advance.
You can do one thing to solve this problem. Create a hidden menu of all the article links which are linked in the sliders.By creating hidden menu the link will be initialized and $menu->getActive() will work for all the links..Hopefully it will works for you .
I wish to add to the present answer and provide some clarifications.
In order for the menu selection to be detected the page requires to be assigned to a menu item. If this is a hidden menu than the link to such a page called My Page would be:
/index.php/my-page - “my-page” is the menu title alias for this item
However, if one wants to show the correct hierarchy in the breadcrumbs for the same page, then the menu hierarchy would have to be replicated in the hidden menu.
For example if My Page is under My Articles main menu item, then in the hidden menu you should add “My Articles” item, of the type: Menu Item Alias, which is in the Systems submenu of the menu type field. The My Page item should be a sub-menu item of My Articles.
The “My Articles” menu item in the hidden menu must have a different menu alias than the same one in the main menu hence the new link to My Page would look like:
/index.php/my-articles2/my-page
To create a hidden menu, one simply creates another menu. It does not matter whether one creates a module for it or not, but if one does then one just should not assign any position to that module.
This is my scenario
I have an view(page) with list of items, a user could select single or multiple items from this page and click on a "Add to Group" button. Then a modal dialog(JQuery dialog) will be shown, from that he could select group, then press the add button. Which causes the items selected in the parent page is added to that particular group.
So, which is the best way to pass the selected items to the modal pop-up?
Though the query string ? - what happens if the no:of items selected is large, will the url support that much characters
Keep the list in the parent page in a javascript variable and return the selected group from the modal pop-up?
Or is there is any other better option?
Thanks,
Rajeesh
2a. There is no "parent" page; modal dialog is part of the same page as selected items. Therefore on "OK" function from the dialog you can go through the checked items and do whatever you want, including POSTing to the server. It's not clear from your post whether "adding items to the group" happens on the server or client
I want to have 2 navigation menus- One will be a "Top Level" menu, with 4 choices, each pointing to the index of a separate controller.
I would like to have a "Controller-Level" sub-menu on the left of my screen. This will correspond to links relevant to the controller selected in the top menu.
The "controller-level" menu is not static and needs to be customized based on roles of user.
The top-level one is basic. But how can i create the second menu that will change when a controller is selected from top?
danke!
I'm working on a similar situation where I need two menus. Was a "best-practice" ever resolved here? I have the need for one menu on the left, and a dynamically created tab-like menu at the top depending on what page I'm working with/on.
The user actually needs the ability to add/remove/hide top tabs depending on preferences. We are using MVC 2 and I'm not sure if the tab bar belongs in a control, on individual views, or what...and also how to make them both interact with my pages. (The left nav needs to show where the user is at all times, and the top tab needs to be highlighted based on the sub-page the user has selected.
If you are using MVC 2 RC or MVC Futures, then use RenderAction.
Create a controller for the dynamic menu, and call RenderAction("action", "controller"). This will invoke the controller, and you can have your logic in the controller to show the correct menu.