htmlhelper

ASP.NET MVC Preview 5 - Html.Image helper has moved namespace

We've just updated ASP.NET from Preview 3 to Preview 5 and we've run into a problem with the Html.Image HtmlHelper in our aspx pages. It seems that Html.Image has moved from System.Web.Mvc into Microsoft.Web.Mvc, and the only way we've found to access the helper now is to add an import statement to every .aspx page that uses it. All the...

Html.TextBox conditional attribute with ASP.NET MVC Preview 5

I have a strongly-typed MVC View Control which is responsible for the UI where users can create and edit Client items. I'd like them to be able to define the ClientId on creation, but not edit, and this to be reflected in the UI. To this end, I have the following line: <%= Html.TextBox("Client.ClientId", ViewData.Model.ClientId, new {...

ASP.NET MVC Beta 1 - where is Html.RenderPartial?

I'm just in the process of upgrading my Preview 5 application to Beta 1, and I'm nearly there save for this one error when trying to render a control: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'RenderPartial' and no extension method 'RenderPartial' accepting a first argument of type 'System.Web.Mvc.HtmlH...

Do you use any custom ASP.NET MVC HtmlHelper extensions?

I'm interested in seeing what custom extensions other developers have created for the ASP.NET MVC HtmlHelper class. I think Microsoft got off to a great a start, but as usual, left a lot of open holes to fill! Looks like I am going to have to create some for rendering images, rendering action links as images, and so on. Thought ...

Strange Html.ActionLink() Behavior after Upgrade to Beta 1

I upgraded a large ASP.NET MVC application I've been working on to the latest beta today, and after some initial problems, I've got it mostly working again. The big problem is that I have things like this: <%= Html.ActionLink("LOGIN", "Index", "Authorization", new { redirect=Request.Url })%> and <%= Html.ActionLink("Edit this page"...

Html.ActionLink in asp.net MVC object value in wrong format

I have a html.actionlink that i wish to display a link to a members profile page like this: http://somesite.com/members/{username} When use the following markup <%= Html.ActionLink(r.MemberName, "profile", new { MemberName = r.MemberName } )%> I get a link that looks like this: http://somesite.com/members?MemberName={username} What ...

ASP.NET MVC HtmlHelper extensions for YUI controls (Yahoo User Interfaces)?

Has anyone written any HTMLHelper classes for MVC that help with Yahoo's User Interface Library? For instance I have written a helper method to convert a 'menu model' into the HTML markup needed to support the Yahoo Menu Control. The MVC pattern works well here because obviously if I chose to switch to a different menu implementation I ...

ASP.NET MVC Html.ActionLink result URL - the way of encoding

Hi All, I create an amount of actions in MVC controllers. public ActionResult DoSmth1(string token) public ActionResult DoAnother2(string token) And when I have to call ActionLink.. =Html.ActionLink<SomeController>( x=> x.DoSmth(item.property), item.property) =Html.ActionLink<AnotherController>( x=> x.DoAnother(item.property), item....

How do I access HtmlHelper methods from within MY OWN HtmlHelper?

I am writing my own HtmlHelper extenstion for ASP.NET MVC: public static string CreateDialogLink (this HtmlHelper htmlHelper, string linkText, string contentPath) { // fix up content path if the user supplied a path beginning with '~' contentPath = Url.Content(conten...

Extending/replacing Html.Image for Amazon S3 (or other CDN)

Just want to confirm that there is no way to extend or replace Html.Image functionality without writing a replacement function. I want to write a function that will use Amazon's S3 service for hosting images. The best approach I've come up with is a helper method Html.SmartImage which would check a configuration property to see if i wa...

How do I use ASP.NET MVC Html.RouteLink in Visual Basic?

I think in C# you can create in-line RouteValueDictionary instances like this: <%=Html.RouteLink(Model.Name, "SomeRoute", new { id = Model.Id }) %> What's the equivalent in Visual Basic? This works, but is quite wordy: <% Dim d As New RouteValueDictionary() d.Add("id", Model.Id) %> <%=Html.RouteLink(Model.Name, "SomeRoute",...

Accessing HtmlHelper methods within HtmlHelper extension method - ASP.NET MVC RC2

I am trying to build an HtmlHelper extension in ASP.NET MVC RC2. This code worked fine in Preview 5, but does not work anymore in RC2 and I am trying to understand why. Here is the code: public static string EmptyDropDownList(this HtmlHelper htmlHelper, string name, object htmlAttributes) { return htmlHelper.DropDownList(name, new S...

Can I make ASP.NET MVC Html.RouteLink() return a url for my home page without an ID?

I've got a single route in my Global.asax.vb page like this... Shared Sub RegisterRoutes(ByVal routes As RouteCollection) routes.IgnoreRoute("{resource}.axd/{*pathInfo}") routes.MapRoute( _ "IdOnly", _ "{id}", _ New With {.controller = "Page", _ .action = "Details", _ ...

Is there an ASP.NET MVC HtmlHelper for image links?

Possible Duplicate: ASP.NET MVC Ajax.ActionLink with Image The Html.RouteLink() HtmlHelper works great for text links. But what's the best way to link an image? ...

HtmlHelper methods and RouteValueDictionary

When writing an htmlhelper extension if I want to support the similarly structured ctors for my htmlhelper extension method, I use RouteValueDictionary as follows: public static string ListBoxDict(this HtmlHelper htmlHelper, string name, object value, ...

Do ASP.NET MVC helper methods like Html.DropDownList() encode the output HTML?

I am just wondering if I have to worry about encoding the values that get output when I use HTML helpers like Html.DropDownList(). If so, how do I encode them? It's easy to do if I were building the drop down manually -- just wrap each value with "Html.Encode()". However, I don't know how to do this when using HTML helpers. ...

ASP.NET MVC Html.TextBox @class = "MyClass" not working

I am using the Html.TextBox helper method to generate a textbox against my model but when i pass in an anonymous htmlAttributes class with @class defined like below, the class is never assigned. Am I doing something wrong? I have assigned a readonly attribute the same way and it worked. <%= Html.TextBox("LastName", Model.LastName, new...

ASP.NET MVC - Is it possible to generate cross-application action links?

Hi, is it possible to generate cross-application action links using the HTML helper class? I have the following (both are separate VS2008 projects): http://mainwebsite/ http://mainwebsite/application I would like to generate a link IN the /mainwebsite/application/ project TO /mainwebsite/. Is this possible? Or should I just hardcod...

There is no ViewData item with the key 'Blah' of type 'IEnumerable<SelectListItem>'.

This error message is driving me nuts. I'm getting it when using Html.ListBox and Html.DropDownList HtmlHelpers with ASP.NET MVC v1.0. Populating the lists works OK - I can view them, etc - but when I go to create a new record in the Model using the FormCollection passed into the Controller to get the selected value, this error occurs. ...

Create a url link with an ID for an action

Hi, In my view page, I want to link to the action "Display" and pass it the ID that the action expects as a parameter. Which html helper do I use? I don't want it to create the a href page of the string, just the url. ...