I’m new to .net mvc and have become stuck when rendering data in my view.
I’m creating a small project management tool and I am currently working on the project admin section.
I’m sending a model that contains a list of all projects that a user has to a view that administers projects. The project list is rendered in a table. The model contains everything relating to the projects, phases, project users etc.
When I click on a row in the table, I would like to render the extended detail of that project below that table so it will display users and phases of the selected project.
With jquery I can do this, but I would like to code this event in the view using .net code and not use Jquery. My main objective is not to call back to the server as I have all the data available in the model.
I’ve searched around and can’t find that much detail about triggering events and rendering further detail on a page. I understand what partials do, but that would mean calling back to the server.
What is the best way to approach this type of problem? Should I just use JQuery? If I do use jquery, how do I then use html helpers in the script, if the script is not in the page?
You could have a form inside each row and a submit button to show the detail. When the submit button is clicked a controller action will be invoked and set the selected row project id which will use it to retrieve the project detail and passed back to the view. You will also need to retrieve the whole list of projects because in order to be able to redisplay the table as well. Your main view model will consist of a property representing the collection of all projects and another property containing the selected project details. Initially the details property will be null. When a project is selected you will assign it. Then inside the view you could test if the details property is assigned and render the details in a partial.
If you decide to use jQuery and AJAX then since you won't be redisplaying the entire page, you don't need to retrieve the project list for the view model in the details action. Only the details. And then simply refresh the corresponding section of the DOM with the partial returned by the action.
Related
I cannot seem to figure out how to add my preexisting pages to the auto navigation menu that Piranha generates when I call #UI.Menu().
Currently, I am using the method described here under Getting the Models to pull CMS content and display it above my model data. I can successfully render the page with Piranha content, but I'm not sure how I can have this page display in the top navigation.
Alternatively, I can pull my data and display the CMS content by creating a new page type, but this means the page type is only ever used to display this single page. It shows up in the navigation generated by #UI.Menu(), but if I continue using this method, I would need to create an additional piranha controller for every Action.
My main objective is adding CMS functionality to my custom MVC project and have everything display in an automatically generated navigation with #UI.Menu().
If you want to add pages in the menu that aren't really controlled by the CMS add a single page type for them, for example "Application Page". Then check the documentation for page types under section 2.5 here http://piranhacms.org/docs/pages/page-types.
If you check the checkbox to allow pages to change the route you can specify the route on each page of this page type. This means you can add your application pages into the structure and the add the route to your controller/action.
I've been writing a code library for ASP.net MVC4 I'm called "ExpressForms". The idea is to automate common coding tasks associated with displaying tabular data.
Recently, I started writing code that will automatically display a "filter" widget for each column in the grid so that the user can type to find certain records. The filter automatically adapts to the data type associated with each column and adds a rich set of features, such as autocomplete, and page state bookmarking.
To implement these features, I've created some partial views that the associated classes use to output HTML to render these widgets.
The issue I have is that once someone downloads the library, they must manually copy the partial views to their ASP.net MVC4 project! Is there a way to configure my library (which is a .net class library project) so that a developer who downloads my library doesn't have to manually copy the partial views into his web project?
This is repeatedly asked many times, however i couldn't find appropriate solution for my problem.
I want to create an Entry Form which will consists of following elements:
Text boxes, drop down fields (auto populated) , check boxes , radio buttons
After my research
i found that i need to create user control, or script file for above form and access it via Macro.
I don't want to use User control as my first preference is to controller-View-Model (i.e. cshtml)
I want to follow MVC approach to create above form. So
1) Do i need to create a seperate project for Add/Edit/Delete/Search Data Entry form?
2) OR i need to create cshtml file for the same(not so clear about this approach)
I'm looking this data entry form with easier for customization and i could use it in other applications as well.
From Umbraco 4.10 up to 6.0.x you can use MVC in Umbraco so there's no need to use an usercontrol. You probably want to use a SurfaceController where you can add any Action you want. The rest is standard MVC (Razor views to build your textboxes, drop downs, ...).
Check out the Umbraco MVC documentation where they explain how to use MVC in an Umbraco project.
Hi
I want to make reusable component in/for Struts 2 framework. For example, a login form having validations, authentication on form submission, error display, Forgot password link etc.
I want to create this form in such a way so that it can be placed anywhere within the site and in any site without any changes.
Please suggest what should I use or better if you can provide and reference for the example of such type of components.
Thanks
Krishan Babbar
Why not, this is Model View Controller, source code can be reused, for example if you want to go to another framework, everything you will need to modify is View, because each framework has its specific tags, you could do everything with simple html tags, but this is already a framework problem
I have been having multiple problems with getting the Add View.. “Create a strongly-typed view” dialog box option to work properly.
Most of the time, I am unable to get the Model classes to show up in the “Model Class” drop down. This last issue is with Entity Framework classes that have been generated within the Model folder (and namespace). I Rebuild the project and they still fail to show up.
In fact, if I add a test class to the Model folder with a few public properties—it is not showing up in the drop down.
Is their any information available on how this drop down pulls the Model classes to display to the end-user?
Regards,
Normally rebuilding the project should be enough to show your custom class. But unfortunately this is far from perfect. Happens to me also. What I do is that I create my view model (not entity framework model because you should be passing only view models to your views), copy the name into the clipboard and paste it in the Add View dialog. I find this faster than scrolling through a dropdown of 1000 classes and finding the correct one.