2

How would I use the ASP.NET AJAX Controls in MVC3?

e.g. Masked Edit Box

I've installed AJAX Control via NUGET.

and tried adding Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" to the top of the page. but it is not recognised.

And I wonder if its even possible in MVC3 since Ive Never used the toolbar. It would make life so much easier If I could use these tools.

IAmGroot
  • 13,760
  • 18
  • 84
  • 154

2 Answers2

2

Any ASP.NET server control is meant to be used in Webforms, not in MVC.

You'll have to find some other HTML helper method to do that or create one yourself so that you may call it like this in your page:

@this.Html.MaskedEditorBoxFor(m => m.WhateverProperty)
Fabio Milheiro
  • 8,100
  • 17
  • 57
  • 96
  • Perhaps take my link and wrap it in an HTML Helper method. :) – Anders Marzi Tornblad Feb 06 '12 at 09:54
  • @atornblad, absolutely, or better yet an editor template. I think your answer couldn't be accepted because you could use the aspx view engine in an MVC project but still not be able to use server controls (because it's MVC). – Fabio Milheiro Feb 06 '12 at 13:47
1

Those controls are designed for the aspx rendering engine. If you are using the Razor engine, you need to look up other alternatives for the masked edit box, like some jQuery plugin.

I found this: http://digitalbush.com/projects/masked-input-plugin/

Haven't used it, so I cannot vouch for it...

Anders Marzi Tornblad
  • 18,896
  • 9
  • 51
  • 66