2
голосов
1ответов
1286 просмотров

passing css class name to asp.mvc view helper

In ASP.NET MVC view helper, you can do something like <%= Html.ActionLink("click me", "DoSomething", null, new { someAttribute = "a value" } ) %> which will produce the following HTML <a href="DoSomething" someAttribute="a value">click me</a> My question is.... what if I ...

2
голосов
4ответов
2407 просмотров

Controlling Output Indentation in ASP.Net MVC

My colleague is extremely 'hot' on properly formatted and indented html being delivered to the client browser. This is so that the page source is easily readable by a human. Firstly, if I have a partial view that is used in a number of different areas in my site, should the rendering engine be a...

0
голосов
1ответов
2444 просмотров

View data dictionary overriding model data in ASP.NET MVC

I have a view to create a user as follows. <% using (Html.BeginForm("SaveUser", "Security")) {%> <p> <label for="UserName">UserName:</label> <%= Html.TextBox("UserName") %> <%= Html.ValidationMessage("UserName", "*") %> </p&g...

4
голосов
1ответов
1380 просмотров

Using EditorFor<> to render a drop-down list

So far we can use Html.EditorFor() to dynamically render the appropriate template for a datatype - e.g. string, int, or a custom type, say 'Address'. Now I want to use EditorFor() to render a 'Parent' field. I want a drop-down containing every row, and the user picks a parent from this drop-down...

0
голосов
1ответов
489 просмотров

skip or disable links to current path in ASP.NET MVC

I'm writing an helper that basically receives many RouteValueDictionary and returns many links; I'd like to skip links to the current route values (example: in /Products/Details/3 there should not be a link to /Products/Details/3), ignoring other URL params if any. What I can think of is to chec...

4
голосов
3ответов
1373 просмотров

What is the difference, if any, between string.Format and TagBuilder in ASP.NET MVC?

I have a Html Helper file for my ASP.NET MVC application. The majority of them simply return a formatted string. Here is an example of one of my formatted string helpers: public static string Label(this HtmlHelper helper, string @for, string text) { return string.Format("<label for \"{0}...

0
голосов
1ответов
227 просмотров

How should I make this? With an Table cell Html helper or some other way?

I am using asp.net mvc and I am not sure how to approach this problem. I have a table in my database and that has some fields in it. I want to generate a table with this. So I first tried to make a html helper that would make the table and and all the stuff I need but I am finding it too hard to...

104
голосов
7ответов
179269 просмотров

How do I apply a CSS class to Html.ActionLink in ASP.NET MVC?

I'm building an ASP.NET MVC application, using VB.NET and I'm trying to apply a css class to a Html.ActionLink using the code: <%=Html.ActionLink("Home", "Index", "Home", new {@class = "tab" })%> But when I run the code I receive the below error: Compiler Error Message: BC30988: Type...

169
голосов
3ответов
61045 просмотров

Generate URL in HTML helper

Normally in an ASP.NET view one could use the following function to obtain a URL (not an <a>): Url.Action("Action", "Controller"); However, I cannot find how to do it from a custom HTML helper. I have public class MyCustomHelper { public static string ExtensionMethod(this HtmlHelper...

6
голосов
3ответов
10134 просмотров

ASP.NET MVC html helpers not working

I hope somebody can help me. I've been trying to write a custom html helper for my MVC application. First at all, i tried with a testing one, which only writes a tag for the specified param. The things is, it does not work unless I explicitly import the namespace. I've been reading a lot and as ...

1
голосов
1ответов
6553 просмотров

.input-validation-error class not added to input in view

I am trying to add some simple validation to my asp.net mvc form and am having trouble getting the .input-validation-error class to be added to my inputs. The validation-summary-errors and .field-validation-error work fine. Thanks in advance for your help! Edit: Thanks for everyone's help!!! ...

0
голосов
2ответов
1068 просмотров

Reusing ViewPage/HtmlHelper in seperate project in ASP.NET MVC using C#

I want to use the ViewPage/HtmlHelper class in the System.Web.Mvc namespace in a seperate project. I imported the relevant libraries and then tried this: using System.Web.Mvc; using System.Web.Mvc.Resources; using System.Web.Mvc.Html; public static class Display { public static string Check...

15
голосов
4ответов
2574 просмотров

Are ASP.NET MVC HTML Helpers overrated?

It is quite possible that I may not have got the point, but I really can't figure out how ASP.NET MVC's HTML Helpers can help me. Here's a sample: - HTML: <a href="ActionName" target="_blank">Click Me</a> HTML Helper: <%= Html.ActionLink("Click me", "ActionName", null, new {ta...

18
голосов
4ответов
9439 просмотров

Using an MVC HtmlHelper from a WebForm

I'm in the process of adding some UI functionality to a hybrid WebForms/MVC site. In this case, I'm adding some AJAX UI features to a WebForms page (via jQuery), and the data is coming from an MVC JsonResult. Everything is working 100%, with one exception: I would like to implement the XSRF pr...

1
голосов
2ответов
5456 просмотров

How to add CSS class attribute for Html helper methods in asp.net mvc (VB.NET)?

Name: <%= Html.TextBox("txtName", "20", new { @class = "hello" }) %> I want that in VB.NET , is it .cssclass="hello" or is it something else?

0
голосов
3ответов
1207 просмотров
1
голосов
1ответов
1750 просмотров

ASP.Net MvC framework, Html.ValidationMessage tag

In this code in an Edit view, the correct vendor name text appears but it is not validated when I blank its textbox and push Save. The Vendor is a property of the Order model, and VendorName is a property in the Vendor model. They relate referentially. My form does not all input into a single tab...

1
голосов
4ответов
3647 просмотров

ASP.NET MVC: 'Extend' Html.TextBox to conditionally have CSS value?

I would like to extend ASP.NET MVC's TextBox so it conditionally switches its CSS value (based on data from the Model). However, I don't want to put that logic in my view (by conditionally changing htmlAttributes/via method call there), but instead extend the class so I don't clutter my view. Bas...

6
голосов
3ответов
5549 просмотров

How does the Html Helper, RenderPartial, work? How can I implement a helper that can bring in content from a partial view?

When you use Html.RenderPartial is takes the name of the view you want to render, and renders it's content in that place. I would like to implement something similar. I would like it to take the name of the view you want to render, along with some other variables, and render the content within a...

0
голосов
1ответов
511 просмотров

How to include dynamic markup in inline XML without it being encoded

I would like to create a HtmlHelper function for a specific kind of dropdown that appears on many pages in my app. I'm basically just trying to add some decoration around the existing DropDownList function, but it's being encoded. Here's my extension method: <Extension()> _ Public ...

1
голосов
2ответов
2536 просмотров

ASP.NET MVC - Implicit Form Action

I have a form which is part of a partial view and I need to submit it to a different location based on the context of the view containing the form. I can't use Html.BeginForm because the form has a multipart/form-data enctype so having the action filled in automatically is out the door. Is there...

2
голосов
4ответов
2447 просмотров

Why can't I specify a `name` attribute in an ASP.NET MVC form using Html.Helpers?

I am playing around with the ASP.NET MVC Html.Helpers and I noticed that say for instance: Html.Textbox("test"); will render the name attribute to "name=test" and the id tag will be "id=test" But when I do this: <%= Html.TextBox("go", null, new { @name = "test2", @id = "test2", @class =...

1
голосов
3ответов
1010 просмотров

Dynamic Object Properties in a MVC Helper on a Entity Framework object

I am new to vb9 and the .NET MVC. I want to build a MVC helper function for which I pass a Entity Framework object and have it build a select. Generally speaking I tried something like this: Public Function RenderSelect(ByVal helper As HtmlHelper, ByVal sSelectName As String, ByVal aItmes As Ar...

2
голосов
2ответов
6249 просмотров

ASP.NET MVC Html Helpers - is Response.Write needed?

When using the Html helpers for ASP.NET MVC I need to wrap them in a Response.Write else they don't appear. However the samples (1&2 for example) I find online for ASP.NET MVC don't seem to do that. Did something change somewhere or am I doing something wrong? From the samples I find it shou...

5
голосов
1ответов
1776 просмотров

Как выполнить привязку модели с помощью JQuery Ajax

Я хотел бы использовать привязку модели, чтобы мои контроллеры выглядели чище, вы можете увидеть, насколько лучше использовать привязку модели: public ActionResult Create(Person personToCreate) { //Create person here } против public ActionResult Create(string firstName, string last...

4
голосов
2ответов
7868 просмотров

Пользовательский метод расширения HtmlHelper недоступен в представлении?

Я перевел Джереми Кларка CheckBoxList Helper для MVC в мой проект VB.Net, но когда я пытаюсь использовать метод в моем представлении, я получаю сообщение об ошибке 'CheckBoxList' is not a member of 'System.Web.Mvc.HtmlHelper(Of Attenda.Stargate.Web.UserRolesViewModel)'. Может ли кто-ниб...

1
голосов
2ответов
2149 просмотров

ASP.NET MVC Html.TextBox не компилируется во время выполнения - те же файлы работают в других проектах

У нас есть два отдельных клиентских проекта для одной компании, которые в основном одинаковы, за исключением HTML и CSS. (Различные подразделения внутри одной компании) Я пытаюсь добавить страницу, которая была построена одним, к другому. (Да, да, я знаю, что нам, вероятно, следовало создать одн...

10
голосов
5ответов
6462 просмотров

Связывание модели при отправке формы с несколькими моделями из строго типизированного представления

У меня проблемы с привязкой к форме с отправкой нескольких моделей. У меня есть форма жалобы, которая включает информацию о жалобе, а также информацию о подателях "один ко многим" Я пытаюсь отправить форму, но при привязке возникают ошибки. ModelState.IsValid всегда возвращает false. Если я о...

0
голосов
3ответов
3263 просмотров

проблемы с ASP MVC + Html.DropDownList () с использованием шаблона ModelView

Недавно я разместил вопрос о раскрывающемся списке помощника html, и он заработал ( здесь ). Но теперь я решил, что было намного разумнее переключиться на ModelView Patterns, поэтому у меня есть доступ к строго типизированным методам в моих представлениях и т. Д. Я сделал некоторые изменения в к...

1
голосов
5ответов
4111 просмотров

Не удается создать методы HtmlHelper в приложении VB MVC

Я не могу понять, что мне не хватает в следующем коде. У меня есть метод, который должен добавить (фиктивное) вспомогательное расширение: Imports System.Runtime.CompilerServices Namespace HtmlHelpers Public Module HelpExtensions <Extension()> _ Public Function Hel...