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
42
votes
4 answers

MVC 4 - how do I pass model data to a partial view?

I'm building a profile page that will have a number of sections that relate to a particular model (Tenant) - AboutMe, MyPreferences - those kind of things. Each one of those sections is going to be a partial view, to allow for partial page updates…
MattSull
  • 5,514
  • 5
  • 46
  • 68
39
votes
5 answers

Minify HTML output from an ASP.Net MVC Application

This is likely a duplicate of the below question but the only answer is a dead link: Minify Html output of ASP.NET Application When working with ASP.Net one of the more annoying aspects to me is the fact that Visual Studio puts spaces instead of…
mynameiscoffey
  • 15,244
  • 5
  • 33
  • 45
25
votes
5 answers

How to render a Section in a Partial View in MVC3?

In a MVC3 project, I have a "_Layout.vbhtml" file with this code ... @RenderSection("Scripts", false) …
9
votes
2 answers

Add CSS class to Html.ActionLink

I want to style a link in my page and am using Html.ActionLink to create the link. The problem is I don't know how to style the resulting link. How do I add a CSS class to the Html.ActionLink in order to style it?
Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304
7
votes
2 answers

ASP.NET MVC Render View to a string for emailing

I want to use MVC views to create the body for an email and I have come across this (http://www.brightmix.com/blog/renderpartial-to-string-in-asp-net-mvc/) but it doesn't seem to work with strongly typed views (ViewContext is null). But I was after…
Andy
  • 305
  • 1
  • 4
  • 14
6
votes
3 answers

ASP.NET MVC 2 Model with array/list

I am in the process of creating my first site in ASP.NET MVC, it is a kind of learn as you go. But I have hit a problem that I just can't find a solution for. I want my user to be able to create an album with songs and tags attached. That can be an…
Androme
  • 2,399
  • 4
  • 43
  • 82
6
votes
1 answer

How do I upload a file to Azure blob storage from a MVC view

I am coding a MVC5 internet application and would like some help to upload a file from my own filesystem to an Azure Blob. Here is my Azure upload code function: public void UploadFileToBlobStorage(string containerName, string blockBlogName, string…
Simon
  • 7,991
  • 21
  • 83
  • 163
5
votes
1 answer

System.Web.HttpCompileException:The type '<>' is defined in an assembly that is not referenced

Found this error just after upgrading the .NET framework to 4.7.2: System.Web.HttpCompileException: some.cshtml(95): error CS0012: The type 'IEnumerable<>' is defined in an assembly that is not referenced. You must add a reference to assembly…
MiguelSlv
  • 14,067
  • 15
  • 102
  • 169
5
votes
3 answers

C# view as embedded resource always show a old view after building

I have a MVC2 website which uses views from other assemblies. To do this, I marked the view as "Embedded Resource". I was able to see the view but now, when I change the view I can't see the changes anymore. The way I call the view as an embedded…
Jan
  • 9,858
  • 7
  • 26
  • 33
5
votes
3 answers

what exactly is strongly typed View data in Asp.Net MVC

What is meant by "strongly typed view data" in Asp.Net MVC ? Thanks
Asad
  • 21,468
  • 17
  • 69
  • 94
4
votes
3 answers

Reuse MVC View for both Display of Data and Editing of Data

I have two MVC views... one for displaying details and one for editing the values. They use almost identical templates with the exception that the DisplayFor is changed to the EditorFor when switching to the editor view. How can I reuse the my…
bigmac
  • 2,553
  • 6
  • 38
  • 61
4
votes
2 answers

Why do ASP.NET MVC3 Areas and Razor Views produce this error?

The view at '~/Areas/SomeArea/Views/List/Index.cshtml' must derive from ViewPage, ViewPage, ViewUserControl, or ViewUserControl. The project structure is pretty much default. There is one area called SomeArea. It has a single controller called List.…
Aaron
  • 41
  • 1
  • 3
4
votes
1 answer

MVC 5 - A potentially dangerous Request.Form value was detected from the client

I am developing an MVC5 internet application and have a question in regards to user input having HTML data. I understand that if I want to have HTML code in a model, I can include the [AllowHtml] data annotation and then sanitize the objects…
Simon
  • 7,991
  • 21
  • 83
  • 163
4
votes
3 answers

Should JavaScript and CSS go in views?

I have my ASP.NET MVC project. I have a _Layout, a controller, and some views. Some of the code is obviously global. For example _Layout CSS and CSS that is common across the site would definitely go in a global css file. But when styles and…
user2102611
4
votes
4 answers

How to Put Javascript into an ASP.NET MVC View

I'm really new to ASP.NET MVC, and I'm trying to integrate some Javascript into a website I'm making as a test of this technology. My question is this: how can I insert Javascript code into a View? Let's say that I start out with the default ASP.NET…
Maxim Zaslavsky
  • 17,787
  • 30
  • 107
  • 173
1
2 3
11 12