Questions tagged [asp.net-mvc-views]

A view is a standard (X)HTML document that can contain scripts. You use scripts to add dynamic content to a view.

To make it easier to add content to a view, you can take advantage of something called an HTML Helper. An HTML Helper, typically, is a method that generates a string. You can use HTML Helpers to generate standard HTML elements such as textboxes, links, dropdown lists, and list boxes.

167 questions
2
votes
1 answer

How to render XML data from controller to view efficiently

I am working on a project that requires that I render XML data (that would be my model). Its basically going to be represented in a row - column format similar to your standard database representation. Except you should be able to click on a row…
SoftwareSavant
  • 9,467
  • 27
  • 121
  • 195
2
votes
1 answer

MVC - open page in View mode

Hi I am trying to see if anybody has a briliant idea on how to implement View mode concept in MVC. So if the user opens a page, the page should open in view mode (all controls disabled), if they dont have edit priviledges else should open as normal.…
Amitesh
  • 677
  • 1
  • 10
  • 24
2
votes
1 answer

Showing definition list , dt, & dd on the same line

I want to show a few rows of data on a Details page, which each have a title and data on the same row. The data is showing fine, but since my titles are a little long, it is not fitting on the same line. It extends to the next line. For example, I…
StraightUp
  • 205
  • 1
  • 5
  • 18
2
votes
2 answers

Rendering a View in MVC then immediately redirecting

What I am trying to do is render a View in an MVC site informing the user to not refresh their browser while server side processing is taking place. This could be a long running task, and if they hit refresh it will send the request again, thus…
beatn1ck
  • 538
  • 5
  • 6
2
votes
1 answer

How do I redirect to a action result in a mvc view

When coding a MVC 5 view, how do I redirect to a specific action result specifying the controller, action result and a parameter? I am wanting to redirect to this action result in a Dashboard controller: public ActionResult Location(long id) { } I…
Simon
  • 7,991
  • 21
  • 83
  • 163
2
votes
2 answers

Error when declaring and using a string

How can I reference a variable that I have created in a MVC Razor View? I have declared a variable as follows: @string bootstrapCSSPath = @Path.Combine(Model.pathToResourceDirectory, "bootstrap/css/bootstrap.min.css"); Now I wish to use this…
Simon
  • 7,991
  • 21
  • 83
  • 163
2
votes
2 answers

Conditional statement in MVC View

I don't understand why my view has a runtime error. @if (Model.PicturePath != null) {
@Html.DisplayNameFor(model => model.PicturePath)
@Html.DisplayFor(model => model.PicturePath)
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(); } …
2
votes
2 answers

How to show aggregate data while using Model.GroupBy in MVC views?

In addition to the detail rows in my view, I would like to show some aggregate data like "count" and "sum". I have a picking lists table, and apart from displaying the list lines organized by SKU, I would like to show a total per SKU. My PickingList…
Saeed Fattahi
  • 23
  • 1
  • 4
2
votes
1 answer

add folders for mvc4 view engine to look for views in

I am working with MVC4 and want to set come custom locations for the view engine to look for views in. At present it will only look in the Shared folder outside of the folder it expects the view to exist in. I want to add 2 more folder locations for…
amateur
  • 43,371
  • 65
  • 192
  • 320
2
votes
3 answers

How to handle "magic strings" in MVC views, e.g. element id:s?

In my MVC views I frequently need to reference various elements from JavaScript, and for that purpose I define the id attribute for those elements. This is often in conjunction with Ajax calls that update content of various container elements. A…
Kjell Rilbe
  • 1,331
  • 14
  • 39
2
votes
1 answer

how to have two forms in one View, working separately and well, in ASP.NET MVC 3?

I have two action methods. One of them submits the inserted data of a "new product", and the other form must upload the photos of that product. Each one has it's own Model, View, and each one calls it's own Action from controllers, which are…
Ali
  • 1,152
  • 2
  • 14
  • 33
2
votes
2 answers

MVC ASP.Net how do I add a second model to a view? i.e. Add a dropdown list to a page with a html grid?

I have been able to find lots of examples of adding a Dropdown list to a view but I need to add a dropdown list to a view that also has a Webgrid on it. This entails two different models and from what I see I can only have one per view. The DDL…
John S
  • 7,909
  • 21
  • 77
  • 145
2
votes
0 answers

How to get the view object (System.Web.Mvc.IView)

How can I retrieve a view object in the same project from any controller? This StackOverflow answer suggests using System.Web.Mvc.ViewEngines.Engines.FindView but I can't derive an System.Web.Mvc.ControllerContext instance from…
xster
  • 6,269
  • 9
  • 55
  • 60
1
vote
1 answer

MVC - The call is ambiguous between the following methods or properties

I can't figure out why I'm getting this error. I only have one class with one method in my project that looks like: public static class Extensions { public static string Chop(this string s, int length) { ... return ""; …
Rivka
  • 2,172
  • 10
  • 45
  • 74
1 2
3
11 12