Questions tagged [html-helper]

Refers to the `HtmlHelper` class for ASP.NET MVC views.

HtmlHelper is a helper class specific to ASP.NET MVC. The platform includes extension methods for this class that can be used to render HTML markup given the model and other inputs.

The canonical example is the DisplayFor method, which renders a display for a given model property. In Razor syntax, it looks like this, which renders the value of SomeProperty belonging to the current model class:

@Html.DisplayFor(model => model.SomeProperty)

The volume of methods available in HTML Helper is extensive, and they make use of data annotations (for string formatting and client-side validation). Their usefulness makes them a core part of the ASP.NET MVC framework.

2251 questions
0
votes
1 answer

BuildUrlFromExpression Adding Area to Url

I have a site with an admin area and I have created a HTML Helper to help me create images of different sizes in my views, with the following. Html.Image(c => c.DisplayImage(img.Filename, 53, 35), "Product Thumbnail") This is my…
Richard Tasker
  • 244
  • 2
  • 12
0
votes
1 answer

How to create my custom helper in asp.net MVC?

I asked this question here on the forum for static link helper, but I got no answers yet. So I decided to create my own helper. I'm trying to create a helper for a static link yy but is displaying the HTML…
ridermansb
  • 10,779
  • 24
  • 115
  • 226
0
votes
0 answers

form submission not working after SSL and does not submitimage

I have a form to submit model, it was working correctly before ssl but does not work when uploading pictures after ssl when we don't upload pictures it's work correctly but when we choose an image and click to submit it's not work. form is here …
0
votes
1 answer

Why type argument cannot be inferred from usage if type argument constraint specifies the type?

I've created an extension method which is supposed to provide table header text for a table containing a collection of items of type IList. Though, the compiler says that TModel cannot be inferred from usage, however, for me it is obvious if the…
Gabor
  • 45
  • 4
0
votes
1 answer

Selecting default value in DropDownListFor html helper not working - ASP .NET MVC

I created a controller which accepts one parameter from query string, this parameter is an integer, and i have a drop down list , i want to set a default value from the list based on the parameter value , but it's not working. I am using…
khaled rimawi
  • 55
  • 1
  • 8
0
votes
2 answers

format htmlhelper date field to dd/mm/yyyyy

I need to encode an htmlhelper date to "{0:dd/mm/yyyy}. Current result in dd/mm/yyyy hr:mins:sec <%= Html.Encode(Model.myTable.DOB)%> I also need to enforce a datepicker to format "dd/mm/yyyy". <%= Html.DatePicker("DOB",…
dmarkez
  • 73
  • 1
  • 2
  • 11
0
votes
0 answers

ModelState is false when setting HtmlHelperDropdown list as disabled

I want to show that if data does not exist then the dropdown will work normally but when the data exist then the drop-down will be disabled. I tried read-only but it is also not working for dropdown while it is working for the textbox. @if…
Nabid
  • 197
  • 5
  • 24
0
votes
0 answers

ASP.NET MVC5 - helper acting not with model

Sometimes on pages I must show some data from attributes of different object properties. A.e. when I have a class class A { [CustomAttribute("See me!")] public int B{get;set;} } and want to show data from my custom attribute, I can use smth…
Troll the Legacy
  • 675
  • 2
  • 7
  • 22
0
votes
1 answer

Sending list of objects from view to action

I tried every solution and still my List is null. Can u point me at right direction, I really don't know what is problem... View: @using (Html.BeginForm("EditProfile", "User", FormMethod.Post, new { @class = "form form-horizontal" })) {
Serlok
  • 432
  • 1
  • 10
  • 24
0
votes
1 answer

How do I access atributes of Properties in the model from strongly typed custom HtmlHelper?

I have a view that is strongly typed and its model is of type LogOnModel. That LogOnModel has anotated properties like this one: [Required(ErrorMessage = "Please enter your password")] [DataType(DataType.Password)] [Display(Name = "Password",…
Rasto
  • 17,204
  • 47
  • 154
  • 245
0
votes
0 answers

How to create Combo box field using razor code in C#?

I have a requirement to create a Combo box field, which has a dropdown list and also we can enter text in it. I google it and found datalist tag that is used in the input element to display the dropdown list. Now, my question is, is there any other…
0
votes
0 answers

Using MVC HtmlHelpers, how to send a form with a value from database along with User-filled values?

I'm trying to write a Bank Application. In the Transaction Page, I want to take the value of CheckingAccountId from the User Accounts Database (User.Identity.GetUserId()). But, how should I assign the value of User.Identity.GetUserId() to…
0
votes
1 answer

ActionResult Details needs to resolve FK from List to display Name?

I have a FK in my Details ViewModel and when the View binds to the ViewModel I only get the FK back (expected). The FK is a reference to a simple ID/Name type table. I also have a Strongly typed List in the VM representing that FK-referenced table.…
Bayrat
  • 161
  • 1
  • 3
  • 17
0
votes
1 answer

HTML Helper how to use IEnumerable

I want to create a custom HTML Helper where I can pass a LINQ expression as a parameter, like this: @Html.GetBackgroundColor(model => model.RiskAssessment) I want to use it to display some custom css in an MVC view, depending on what the…
ardmark
  • 81
  • 1
  • 9
0
votes
2 answers

MVC3 Details Action Foreign Key Name Field

Based on great info out here...I've got my edit and create VM working great. My VM contains "SelectList" collections and the DD look like this. @Html.DropDownListFor(model => model.softwaremanufacturerid, Model.ListOfManufacturers) My question has…
Bayrat
  • 161
  • 1
  • 3
  • 17