obautista
obautista

Reputation: 3783

MVC2 Html Helpers

I generated a View using VS 2010 functionality. This auto code generation created this code:

model.DateDeleted, String.Format("{0:g}", Model.DateDeleted)) %>

I created a custom helper method (extension method) to create a JQuery Calendar control. This is the syntax for this control on the View:

How can I bind this to the data coming from my Controller? The Html.TextBoxFor allows a Lambda Expression in its signature. Here is the signature of the DatePicker code:

public static string DatePicker(this HtmlHelper helper, string name, string imageUrl, object date)

I am not sure how to wire the DatePicker with data coming from the Controller. Any help would be very much appreciated.

Upvotes: 2

Views: 2352

Answers (1)

Łukasz W.
Łukasz W.

Reputation: 9755

Instead of using your own html helper use Html.EditorFor which allows you to use lambda expressions. Now prepare editor template with a jquery date piceker to use it as your editor. It will automaticaly display this template if you will put it in EditorTemplates directory. It's a standard in MVC2 and it really is a good practice.

This article shows how to make it! Enjoy!

Upvotes: 3

Related Questions