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

ASP.Net Core 3.1 and global view method

The code @await Html.PartialAsync("~/Views/Shared/_Toast.cshtml", new ToastMessage() { Caption = "Hello", Message = "World" }) renders a partial view with arguments. It shows a Bootstrap toast message, which I intend to use everywhere. Now is it…
hk1980
  • 95
  • 1
  • 7
0
votes
0 answers

Html Helper in partial view, only adding my script once

I have a view that is rendering multiple partial view inside as follow :
@foreach (var view in Model.ViewsToRender) {
0
votes
1 answer

Configure ASP HTML Helper to prevent form from submitting when validation fails

I am learning ASP.NET Core (on .NET 5.0). I have recently used form HTML helper with model validation. But something doesn't seem right. Although the validation fails, client still calls the action and a request is sent to the server. Why? Whatever…
0
votes
1 answer

How to run Html and Url helpers when use Html.Raw - ASP NET MVC

I'm trying to get some html part from database, and when i use Html.Raw(htmlString) helpers render as string instead of execute it. Exemple: @{ var html = ""; } @Html.Raw(html); And that…
0
votes
0 answers

Is there a way to use Controller and View with different name yet still able to display error attribute messages?

I have a View that display a form of field to create new data, then send those data to another controller with different name to execute. The problem is by having different name, I can't display error messages for input field since they don't…
user11131551
0
votes
1 answer

Set current, before current and after current elements in menu

For setting that I use Html helper method which is not the best imo, because I use static field. public enum CurrentState { BeforeCurrent, AfterCurrent } public static CurrentState currentState = CurrentState.BeforeCurrent; public static…
mrzepa
  • 635
  • 7
  • 17
0
votes
1 answer

Acentuation in php, showing latin symbols

I'm writing a program to parse html data from a portuguese website, thing is, when I echo the data I read I get those weird symbols: Meu PC estragou e tenho um netbook que u so para assuntos acadΩmicos. Que…
0
votes
1 answer

i have problem with @html.actionlink not working in mvc

I have a problem with function @html.actionlink and here is my sample code and the error error: Microsoft.Hosting.Lifetime: Information: Application started. Press Ctrl+C to shut down. Microsoft.Hosting.Lifetime: Information: Hosting environment:…
turki
  • 1
  • 1
  • 1
0
votes
1 answer

ADNStoreFront Multistore AddtoCartForm function crashing page

I am trying to modify an existing XML package of Aspdotnetstorefront Multistore. It's an internal XML package to show the variants of a certain product. What I did to start with was to copy-paste the whole code as is and throw it into a new custom…
Yan Kleber
  • 407
  • 2
  • 4
  • 11
0
votes
2 answers

Error CS0104 'HtmlHelper' is an ambiguous reference between 'PagedList.Mvc.HtmlHelper' and 'Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper'

This error was encountered when I was Writing the PagedListPager method. It is showing some ambiguity error. I'm new to this MVC development. I'm not able to figure this out! Any help would be appreciated! the error is showing for this particular…
0
votes
1 answer

Getting the link, not the anchor tag in ASP.NET MVC

I'd like to write: Edit instead of: @Html.ActionLink("Edit", "Edit") Where @Html.LinkGenerator is the name of an imaginary helper which only creates the link, not the whole anchor tag, for a given route and…
Saeed Neamati
  • 35,341
  • 41
  • 136
  • 188
0
votes
1 answer

ASP .NET MVC 5 Checkbox loop for new created values

I have three entity classes: namespace App.Data.Models { public class Employee { [Key] public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public…
izulaa5
  • 39
  • 7
0
votes
1 answer

ASP .Net MVC Model - ViewModel - View

I have a problem with using properties from models in my views. My models: Employee.cs namespace App.Data.Models { public class Employee { public int Id { get; set; } public string FirstName { get; set; } public…
0
votes
1 answer

'System.Action' does not take 1 arguments HtmlHelper MVC3

I'm getting an exception when using html helpers in mvc3. I got the exception originally when using LabelFor and TextAreaFor with a 'virtual' parameter of a class. When I removed the virtual keyword it worked fine. I've now come to add a LabelFor…
Jason Underhill
  • 765
  • 1
  • 10
  • 18
0
votes
1 answer

How to created custom TexboxFor?

I have a textbox that insert only number and add comma separator in it. I use this code in view @Html.TextBoxFor(m => m.TurnRatingCost, null, new { @class = "form-control",onkeyup= "javascript:this.value=Comma(this.value);", onkeydown = "return…
ar.gorgin
  • 4,765
  • 12
  • 61
  • 100