Questions tagged [asp.net-mvc-layout]

22 questions
21
votes
2 answers

ViewStart and Layout - what's the difference?

I have just started reading ASP.NET MVC 4 book and got one question. In the Razor part author said that if i dont set the Layout variable in the View.cshtml file it will as default search for a _ViewStart.cshtml, but in another part he is using…
CSharpBeginner
  • 1,625
  • 5
  • 22
  • 36
5
votes
2 answers

With AMP HTML, is it legitimate to set the link canonical href attribute to pound (#)?

Is it legitimate to set the canonical link to the pound symbol as shown below, or am I required to enter a physical page name? When testing this, the pound setting does not generate a validation error (ala…
Ken Palmer
  • 2,355
  • 5
  • 37
  • 57
2
votes
1 answer

Bad practice to set layout to null?

Is it bad practice to set the layout of an MVC view to null? @{ Layout = null; } // Some Content By 'bad practice', I mean is anybody aware of inner-components of the MVC rendering…
user1017882
2
votes
2 answers

Can an ASP.NET MVC PartialView have a _Layout

Can an ASP.NET MVC PartialView directly use a Layout? MSDN I have looked at MSDN for PartialViewResult and compared with ViewResult: ViewResult has a property MasterName that PartialViewResult does not. But.. I can still define the Layout property…
Scotty.NET
  • 12,533
  • 4
  • 42
  • 51
2
votes
1 answer

Data driven asp.net mvc layout

I have a controller action: public ActionResult Sub(int id) { SubPage_Table subpage_table = db.SubPage_Table.Single(s => s.PageID == id); if (subpage_table == null) { return HttpNotFound(); } …
1
vote
0 answers

How to setup an mvc partial view so that it is not affected by the css of the layout page?

In my asp.net mvc web application I have a razor layout page with a partial view @Html.Partial("_HorizontalNavbar") in it.
Manu
  • 1,290
  • 5
  • 17
  • 32
1
vote
2 answers

How to Implement common jquery data table in layout page

I am working with MVC , In my application we have 30+ pages and all pages have its own grid with its own different data. now I want to implement jquery datatables in all grid Same feature will be implemented to all over application,I am new learner…
1
vote
2 answers

How to send Model to _Layout.cshtml (I need to send another model to Index view too)

I need to send 2 different Models, one to Index view and another one to _Layout.cshtml, how I can do it? My HomeController: [Route("")] public ActionResult Index() { HomeViewModel model = new HomeViewModel(); model.A = _repoA.GetLatest(4); …
1
vote
0 answers

ASP.NET MVC Layout page with dependent dropdowns and context control

I have a site where all pages need a dropdown listing countries and another dropdown containing child data based on the selected country. I have taken a similar approach to this article: MVC 3 Layout Page, Razor Template, and DropdownList So I need…
Spencer
  • 251
  • 2
  • 8
1
vote
3 answers

Layout in ASP.NET MVC

I have started learning Asp.Net MVC and the Problem is that when i add a new view named Index.cshtml it automatically takes Html from Layout Page. I don't know what is happening here. Index.cshtml :- @{ ViewBag.Title = "Index"; } …
Kartikeya Khosla
  • 18,743
  • 8
  • 43
  • 69
0
votes
1 answer

How can I place code in the or element from a PartialView so as to avoid code repetition?

I'm retrieving statistics information from the database in the form and shape of