Add View Dialog MVC3 - asp.net-mvc

I am busy changing the default T4 Templates that gets generated when I click on the "Add View" dialog from my Controller. I know how to change the templates. But the following i can not wrap my head around.
I want to be able to generate the following when the user clicks on Add View.
A partial view that only contains the Form part of the view that is generated by default
A View that calls the partial view generated above.
Is it possible to generate 2 files like this using the T4 Templates ?
thanks in advance

Why? Are you going to be routinely doing this exact same thing over and over again? If so, then a T4 template may make sense. If you're doing it once or twice, then just modify the files by hand.

Related

How can you tell a field name on a view of an MVC application?

I'm new to web programming. I have an MVC application that I want to edit a field on the view. I understand the layout of the URL is {'ClassName' minus Controller keyword/'MethodName'} I don't get how to find the view that I'm looking at though. F12 dev tools don't work worth anything for this either. Please help.
It uses a conventions based approach for view location. By default it should be in the views folder. For example if your controller name is HomeController and your action name is Index then the corresponding view is ~/Views/Home/Index.cshtml.
Right click in the controller Action method, in the options listed you can choose 'Go To View'. This will take you to the view code of the Action of respective controller

Having a fixed menu for some of my Views in ASP.NET MVC

I am trying to have a fix menu on some of my views. For example I have a view called 'Kitchen' and then I have sub views in there. I need to have a fix menu to each view there.
I have been able to menu to each view file but how do I make a separate file for menu on some particular views. I am using razor as template engine.
You have two options:
Use a different shared template (like ...\Views\Shared\_Layout.cshtml) for the views that need a menu. This template can itself use another (like ...\Views\Shared\_Layout.cshtml) for content common with all pages. So this my setting Layout to the relative path to the template.
Use a partial view: another Razor file that is included into the views are renders the menu:
#Html.Partial("_TheMenu", menuModel)
the model parameter, if no model needed, isn't requited.

Rendering controller/action within a different view

I am looking for a way in Ruby on Rails to render a completely different controller's action within other views.
For example I am writing a band website that displays their albums. So I have /albums/list that shows a list of all of their albums with other stuff around the page as the layout. Now what I am looking to do is also render /news/list in every page as part of the layout as well so that every page you go to you can see it.
I cannot find a way to call the news controller list action and display it in the list view using partial views. Any help would be appreciated.
http://api.rubyonrails.org/classes/ActionView/Helpers/RenderingHelper.html#method-i-render
render() method give you ability to render specific file, placed in any directory :)
also read this article - http://blog.plataformatec.com.br/2012/01/my-five-favorite-hidden-features-in-rails-3-2 especially about "Custom partial paths".

how to position partial view in asp.net mvc through java script?

i am using partial view for my project but my problem is that my links are on right side of masterpage and when i clicked on particular link the view should displayed on left side on contentplace holder of master page. but right now its showing exactly below so my whole disgne is distrubed.
how to position partial view in asp.net mvc through java script?
so please if anyone know the solution tell me.
thanks
Do you basically mean your HTML is not set to allow the Content on the left, and the Menu on the right?
Maybe you would benefit from a CSS Layout Template? Put the Content placeholder in large column, and the menu PartialView in the side bar.
It might be a problem with your page CSS. Look at your styles for "Float" 's. If you want your content to be to the left of your page, surround your contentPlaceHolder with a div tag and add a "float:left" style to it.
If that doesn't work it might be your view is wider than your master page design is set up for. So it will pop below every other page element to fit on your page!
This is not realy asp.net mvc specific but html. You will have a better chance to solve your problem if you tag your question as html and css.
You can just save the source (I mean the rendered source from within the browser) of the page that doesnt display properly with the extension html in the root of your web. Then start playing with the html.
Request the page by calling http://yourserver/yourpagetodebug.html.

How to build a tabbed Edit View for a big ViewModel in ASP.NET without JavaScript?

I've got a big ViewModel for a ContactViewModel with several addresses (default, invoice, delivery). This ContactViewModel I would like to edit within a DefaultAddress tab, etc. and I would like to know how to handle this without JavaScript? Is this possible?
Tell me if I'm off base here;
The way i think i'd approach this is to create a partial view which takes a list. the partial view would itterate through the list and create another partial view which is the tab.
on click of the tab i'd do a postback and store the clicked tab. this id then becomes the active tab.
when i come back to rebuild my page, the partialview for the actual tab would need to check to see if it's active and then make itself visible. if not visible then simply render nothing maybe.
This can be done with CSS. Here is an example: http://www.alistapart.com/articles/slidingdoors/
The selected tab/view will need to be rendered on the server. I can see each tab being a link, when the link is clicked the correct view and selected tab is returned.
Some of the css tabs don't work correctly in IE6. I'm not sure if the above link is one of them.

Resources