htmlhelper

How can I add a class attribute via Html.BeginForm?

Hi, I know I can specify form attributes this way: Html.BeginForm("DoSearch", "Search", FormMethod.Post, new { id = "MyForm"})) But what about class attributes? Obviously this does not work: Html.BeginForm("DoSearch", "Search", FormMethod.Post, new { class = "myclass"})) I've also tried new { _class = "myclass"} and new { c...

ASP.NET MVC: Is a helper allowed to grab data?

All my controllers in my project inherit from a base controller, which has a property with my Entity Model. Let say I have a view that shows cities in the world, and it has an option to filter by country. The country filter is a dropdown list of countries from the database. The Html helper for the dropdown list requests a IEnumerable<Se...

A public open source HtmlHelper repository for sharing "controls"

After using the MVC framework for a little while now I must say I love it, but in my opinion there has always been one thing that poops on the MVC party cake. The lack of good, reusable and portable "controls". This is where the HtmlHelpers should kick in. After reading this blog post I started thinking about what exactly I’m expectin...

Adding a onclick dynamically using an Html Helper in MVC

I need the ability to dynamically set an onclick using an HTML Helper. the below is what I'm trying to do, but i'm getting an obvious syntax error <%=Html.CheckBox("checkboxname", item.Id = 3, New With {.onclick = "ajaxThis(this, <%= Html.Encode(item.ID) %>, '<%= Html.Encode(item.NUMBER) %>');"})%> ...

Surrounding a ValidationSummary with a box via CSS

Hi, By default Html.ValidationSummary() produces HTML like this: <span class="validation-summary-errors">There were some errors...</span> <ul class="validation-summary-errors"> <li>First Name too long</li> <li>Invalid Email Address</li> </ul> I'd like to select the entire validation summary and add a bounding box around it via ...

How to dynamically alter the class of an Html.ActionLink in MVC

I'm looking for a way to alter the class of an ActionLink in the controller based on specific criteria (not found in the model so I can't write a conditional in the view itself). But i can't seem to find the ViewData("name") that allows me to work w/ this element (I assume this is possible, but I'm missing something). I have an html he...

Does Html.TextBox uses Request.Params instead of Model?

I have a simple test application: Model: public class Counter { public int Count { get; set; } public Counter() { Count = 4; } } Controller: public class TestController : Controller { public ActionResult Increment(Counter counter) { counter.Count++; return View(counter); } } Vi...

Links in Ramaze with a/r helpers

In ramaze (2009.06.04) the link helper has changed and I have some problems to use it. I want to create a link to the MainController -> test action #{a('Testlink', r(:test))} This works if the URL is not in a specific controller. If the user is in a other controller like http://site/othercontroller/testtwo, the Testlink are linked to ...

.NET MVC - How to create HtmlHelperExtension in VB instead of C#?

Hi, i need to create a HtmlHelperExtension in VB instead of C#. I cannot find any example showing how it's done. Since static classes don't exist in VB (modules are used instead), I'm not really sure on how to create a HtmlHelperExtension... This is what I figured out, but it doesn't seem to work... Public Module HtmlHelperExtensions ...

Can't create HtmlHelper methods in VB MVC app

I can't figure out what I'm missing in the following code. I've got a method that should add a (dummy) helper extension: Imports System.Runtime.CompilerServices Namespace HtmlHelpers Public Module HelpExtensions <Extension()> _ Public Function HelpMe(ByVal HtmlHelper As HtmlHelper) As String Return "<a...

problems with ASP MVC + Html.DropDownList() using a ModelView Pattern

Recently I posted a question about the html helper dropdownlist and got it working (here). But now I have decided it was alot smarter to switch to ModelView Patterns so I have acces to strongly typed methods in my views etc. What I did was I made some adjustments to the code in my other topic in the following way: VacatureFormViewModel:...

ASP.NET MVC Html.TextBox won't compile at runtime - same files work in other projects

We have two separate front end projects for the same company which are basically the same except for all the html and css. (Different divisions within the same company) I'm trying to add a page that was built in one over to the other. (Yes, yes, I know we probably should've built a single app that display different presentations based on...

Custom HtmlHelper extension method not available in View?

I have translated Jeremiah Clark's CheckBoxList Helper for MVC into my VB.Net project but when I try to use the method in my view I get the error 'CheckBoxList' is not a member of 'System.Web.Mvc.HtmlHelper(Of Attenda.Stargate.Web.UserRolesViewModel)'. Can anyone tell me where I have gone wrong? Helper module: Imports System.Runtime...

How to do Model Binding with Jquery Ajax

Hi, I'd like to use model binding to keep my controllers looking cleaner, you can see how much nicer it is using model binding: public ActionResult Create(Person personToCreate) { //Create person here } vs public ActionResult Create(string firstName, string lastName, string address, string phoneNum, string email, string postalCo...

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 should be like this: <div class="row"> <% Htm...

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 Array, Optional ByVal sTitleKeyName As Strin...

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 Function Year(ByVal HtmlHelper As System.Web.Mvc...

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 container.. For example: public static ...

How to get the value of datafieldtext or selectedtext of the selectlist in asp.net mvc?

No javascript\AJAX is to be used. ...

How to add CSS class atttribute 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? ...