Jurjen
Jurjen

Reputation: 794

MVC4 usercontrol?

I'm writing a small mobile-web application using the MVC4 RC.

In this app the user will have to enter various numeric values, to make this user-friendly I'd like the user to be able to enter these values using a calculator-like data-entry-control

         1  2  3
         4  5  6
         7  8  9
            0  <  (< = Backspace)

[PREV] Oplage [......] [NEXT]

This way the mobile-keyboard wouldn't have to be visible and the user can 'tap' on the buttons 1 through 0 and use backspace to correct, the 'tapped-in' value should be displayed in the field next to 'Oplage', when done user should tab 'NEXT' and get the next view in wich he would use the same 'control' and enter the next numeric value.

I have created many usercontrols in standard ASP.NET but am new to MVC and would like some guidance as to what would be the best approach to this.

Jurjen.

Upvotes: 2

Views: 2162

Answers (1)

moribvndvs
moribvndvs

Reputation: 42497

MVC has HTML helpers that you can use to generate predefined HTML (and script, if necessary) for your application. You can extend the built-in helpers with your own via extension methods.

Alternatively, you can create a partial view containing the relevant markup and script, and use @Html.RenderPartial("NumberPad", Model.NumericProperty) (where NumberPad is the name of your partial view and Model.NumericProperty is an integer property on your view model class).

As a variation of the partial view, you can use an editor template (which will ostensibly be the same, just gives you more terse syntax). Keeping your partial view page from above:

 @Html.EditorFor(m => m.NumericProperty, "NumberPad");

Upvotes: 2

Related Questions