7

Currently working on a project in MVC-3. Trying to put the following code in my view, but Visual Studio is telling me it can't find the Serialize method.

@Html.Serialize("User",Model)

(ex)

@using (Html.BeginForm())
{

 @Html.Serialize("User",Model)
    <fieldset>
...
    </fieldset>
}

Is this feature missing in MVC-3? I see examples of people using it in MVC-2. Perhaps there is a new way of handling this issue?

4 Answers 4

6

Html.Serialize is in the Futures assembly.

Sign up to request clarification or add additional context in comments.

5 Comments

Hi Mauricio, Thanks for the response! Any pointers on how to get this working? You can see below in a comment where I'm having trouble getting this to work even though I referenced in the project. Thanks for your time!
@Rob: sounds like a version mismatch (e.g. futures v2 with mvc v3) or framework version mismatch (maybe futures v3 needs .net 4 and you're targeting .net 3.5 ?)
Yeah, that could be... Normally when you add a reference to the project, does it automatically add it to the web.config under the assemblies (because its currently not doing that as I thought it would)? Current runtime version on the dll says v4.0.30319. I compiled it using .NET 4.0 in its own project. Could this be because I'm using an outdated (beta?) of MVC-3? Looks like I installed on 11/15/2010 but don't know how to check the version. Sorry, I'm a bit daft with web development - I'm a WPF programmer by day. Thanks again for your time!
@Rob: AFAIK Futures hasn't been released for MVC3 RC yet, so you might want to make sure you're referencing MVC3 beta and Futures beta.
Thanks again for the info Mauricio! Still can't get it to compile correctly, so I'll wait until the full versions are out and try it again. For now, I'm getting by on using @Html.HiddenFor(m => m.UserID). Thanks again for your time!
6

Install the Nuget package: Install-Package Mvc3Futures.

On your view, add a reference to namespace Microsoft.Web.Mvc, then you can use Html.Serialize.

5 Comments

Thanks man. I'm now using MVC4 and so i install MVC4Futures but when i add Microsoft.Web.Mvc namespace to view i got ambiguous between Microsoft.Web.Mvc and system.web.mvc because of some helper such as image helper exist in both, so do you have any solution for this?
The package you got is Microsoft.AspNet.Mvc.Futures? You have a Microsoft.Mvc.SerializationExtensions class that has two Serialize extension methods.
I see but i want to add namespace above my view and use serialize helper just as "@Html.Serialize" like other helpers.
But can't you put a: @using Microsoft.Mvc; declaration in your view?
That's my fault, Sorry. I'v been confused between some namespaces. I have a namespace with my special image helper and it's responsible for conflict. As I said before I want to use helper in view like standard helper with "@Html.Helper..." syntax, so when i have simultaneous helper in different namespace what can I do? Can you help me please?
2

Serialize() is not listed here.

It is not a part of Sys.Web.Mvc, but is for now part of Microsoft.Web.Mvc:

1 Comment

Thank you for the response! I may be a bit dunce here, but for the life of me I cannot figure this out.. I downloaded the latest from codeplex, compiled, took the Microsoft.Web.Mvc.dll, used Add Reference... . Now I cannot figure out why its not coming up whenever I do an Html.Serialize. I assume that I need to add it in the system.web -> compilation -> assemblies -> section. No matter what I put in there, I keep getting: "Could not load file or assembly 'Microsoft.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. ...." Any pointers?
0

I downloaded the futures, removed reference to its local System.Web.Mvc (v3), and added the release version from GAC, and included the new futures DLL in project.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.