MVC :: Thoughts On Html.Serialize In The MVC Futures
Feb 3, 2011
I'm learning ASP.NET MVC 2 I want to create a wizard-type application. I was reading you can accomplish this with the help of Html.Serialize method in ASP.NET MVC Futures assembly (To help preserve state as you step through views).
I haven't seen that this is even part of MVC 3.0 as well. how certain this feature will be included for sure in the future? I'm a little wary of relying on it being there.
View 2 Replies
Similar Messages:
Aug 31, 2010
I'm trying to use the new Html helper extension Serialize() from the furthure assembly..
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<List<MvcApplication2.Models.ProductViewBinding>>" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace="Microsoft.Web.Mvc" %>>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Index</title>
</head>
<body>
<div>
<% using (Html.BeginForm("Index", "Products", FormMethod.Post))
{ %>
<% int codeIndex = 0;
foreach (var item in Model)
{ %>
<%: Html.TextBox("Encryption[" + codeIndex + "].Value") %>
<%: Html.Serialize("Encryption[" + codeIndex + "].ID", item.ID) %>
<% codeIndex++;
} %>
<%: Html.SubmitButton("Click meh!") %>
<% } %>
</div>
</body>
</html>
Model
[Serializable]
public class ProductViewBinding
{
public object ID { get; set; }
[NonSerialized]
public object _value;
public object Value
{
get { return this._value; }
set { this._value = value; }
}
}
Controller
[HttpPost]
public ActionResult Index([Deserialize] List<ProductViewBinding> Encryption)
{
return View("Index", Encryption);
}
It returns null when posted... but if I remove the [Deserialize] attribute it returns as it should but with the ID still encrypted.
View 1 Replies
Jul 28, 2010
I have a little intranet application I have been writing to manage and run reports on our company's Work Orders and Service Orders. I am running into a user issue where they will make changes to a record, and then navigate away or just X out of the page without ever saving. So I need to come up with some kind of mechanism to prevent them from leaving if they make changes unless the save or discard the changes.
View 3 Replies
Nov 4, 2010
what are the new futures came in asp.net mvc2.. I am looking for View Codding new futures? Controller coding and Seurity?
View 2 Replies
Apr 12, 2010
I've been trying to get the strongly typed version of RedirectToAction from the MVC Futures project to work, but I've been getting no where. Below are the steps I've followed, and the errors I've encountered.
I created a new MVC2 app and changed the About action on the HomeController to redirect to the Index page.
Return RedirectToAction("Index")
However, I wanted to use the strongly typed extensions, so I downloaded the MVC Futures from CodePlex and added a reference to Microsoft.Web.Mvc to my project.
I addded the following "import" statement to the top of HomeContoller.vb
Imports Microsoft.Web.Mvc
I commented out the above RedirectToAction and added the following line:
Return RedirectToAction(Of HomeController)(Function(c) c.Index())
So far, so good. However, I noticed if I uncomment out the first (non Generic) RedirectToAction, it was now causing the following compile error:
Error 1 Overload resolution failed because no accessible 'RedirectToAction' can be called with these arguments:
Extension method 'Public Function RedirectToAction(Of TController)(action As System.Linq.Expressions.Expression(Of System.Action(Of TController))) As System.Web.Mvc.RedirectToRouteResult' defined in 'Microsoft.Web.Mvc.ControllerExtensions': Data type(s) of the type parameter(s) cannot be >inferred from these arguments. Specifying the data type(s) explicitly might correct this error.
Extension method 'Public Function RedirectToAction(action As System.Linq.Expressions.Expression(Of System.Action(Of HomeController))) As System.Web.Mvc.RedirectToRouteResult' defined in 'Microsoft.Web.Mvc.ControllerExtensions': Value of type 'String' cannot be converted to 'System.Linq.Expressions.Expression(Of System.Action(Of mvc2test1.HomeController))'.
Even though intelli-sense was showing 8 overloads (the original 6 non-generic overloads, plus the 2 new generic overloads from the Futures assembly), it seems when trying to complie the code, the compiler would only 'find' the 2 non-gneneric extension methods from the Futures assessmbly.
I thought this might be an issue that I was using conflicting versions of the MVC2 assembly, and the futures assembly, so I added MvcDiaganotics.aspx from the Futures download to my project and everytyhing looked correct:
ASP.NET MVC Assembly Information (System.Web.Mvc.dll)
Assembly version: ASP.NET MVC 2 RTM (2.0.50217.0)
Full name: System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Code base: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Web.Mvc/2.0.0.0__31bf3856ad364e35/System.Web.Mvc.dll
Deployment: GAC-deployed
ASP.NET MVC Futures Assembly Information (Microsoft.Web.Mvc.dll)
Assembly version: ASP.NET MVC 2 RTM Futures (2.0.50217.0)
Full name: Microsoft.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null
Code base: file:///xxxx/bin/Microsoft.Web.Mvc.DLL
Deployment: bin-deployed
This is driving me crazy! Becuase I thought this might be some VB issue, I created a new MVC2 project using C# and tried the same as above.
I added the following "using" statement to the top of HomeController.cs
using Microsoft.Web.Mvc;
This time, in the About action method, I could only manage to call the non-generic RedirectToAction by typing the full commmand as follows:
return Microsoft.Web.Mvc.ControllerExtensions.RedirectToAction<HomeController>(this, c => c.Index());
Even though I had a "using" statement at the top of the class, if I tried to call the non-generic RedirectToAction as follows:
return RedirectToAction<HomeController>(c => c.Index());
I would get the following compile error:
Error 1 The non-generic method 'System.Web.Mvc.Controller.RedirectToAction(string)' cannot be used with type arguments
What gives? It's not like I'm trying to do anything out of the ordinary.It's a simple vanilla MVC2 project with only a reference to the Futures assembly.
I'm hoping that I've missed out something obvious, but I've been scratching my head for too long, so I figured I'd seek some assisstance.
If anyone's managed to get this simple scenario working (in VB and/or C#)
View 1 Replies
May 5, 2010
I´m using mvc futures 2 with WebApiEnabled for XML and JSON support. But due to cross domain issues with jQuery $.ajax I´m lookin in to JSONP. Is there a simple way to extend futures rest function for JSONP or should I do something else.
View 1 Replies
Feb 9, 2011
I downloaded MVC2 Futures and referenced it to my current MVC2 Project. However, if I want to call an HtmlHelper from MVC2 Futures I need to <%@ Import Namespace="Microsoft.Web.Mvc" %>
So I decided to add it on my Web.Config:
[code]....
but, this caused me errors. Could this assemblies co-exist? If yes, How?
View 1 Replies
Jan 25, 2010
Im using DataTable to write some XML. but i got Serialization problem. when i try write i got error message, your datatable is not serialize.(i dont want use DataSet)How i Serialize DataTable?
View 2 Replies
Mar 31, 2011
I'm trying to serialize a Request object for logging purposes. The code
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(obj.GetType());
// obj is a Request object
gives me the following exception:To be XML serializable, types which inherit from ICollection must have an implementation of Add(System.String) at all levels of their inheritance hierarchy. System.Web.HttpValueCollection does not implement Add(System.String).
View 2 Replies
Mar 23, 2010
how we can serialize a datareader in webservices.
View 1 Replies
Mar 20, 2010
How to serialize the DataReader in webservices in asp.net?
View 4 Replies
Jun 14, 2010
I have a shared object through net remoting. The problem is that this object has some EntitySet and EntityRef attributes. When I try to run the program I get an exception telling me that EntitySet is not marked as Serializable. If I mark it as Serializable everything seems to be ok, but when I try to access from outsied to the attribute represented by the EntitySet, I am not able to use it.
BTW, Does anyone know how change the default binary serialization of tcp channel?
View 3 Replies
Jun 21, 2010
I have no problem getting a custom profile class to work as it should in Asp.Net MVC 2, C# -- as long as I am content that the profile info is serialized as xml.The question is how to get it to serialize as Binary, rather than xml -- Is that possible?in the web.config...
<profile defaultProvider="MIProvider" inherits="Models.MbrProfile" automaticSaveEnabled="false">
<providers>
<clear />
<add name="MIProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="MIconnect" applicationName="myApp" />
[code]...
View 2 Replies
Feb 12, 2011
I am facing an critical problem in Enum serialization in WCF. Here is the scenario: I have an enum like this...
[Serializable] [DataContract(Namespace = "http://www.geniusdoc.portal.com/serivces/2011/v1/GdService", Name = "AppointmentMode")] public enum AppointmentMode : int { // 1: Email, 2: Phone [EnumMember(Value = "1")] None = 1, [EnumMember(Value = "2")] Email = 2, [EnumMember(Value = "3")] Phone = 3 }
Here I decorated each enum value with [EnumMember], so that I can use the Enum as Data Contract in WCF.
And, AppointmentMode will be saved as INTEGER in database. So I need to serialize this Enum to its value. So I have specified value to each member like... [EnumMember(Value = "1")]
Problems:
If I use the above code as it is...SvcUtil not considering Enum Text, and generating the Enum in Proxy as below...
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] [System.Runtime.Serialization.DataContractAttribute(Name="AppointmentMode", Namespace="http://www.geniusdoc.portal.com/serivces/2011/v1/GdService")] public enum AppointmentMode: int { [System.Runtime.Serialization.EnumMemberAttribute(Value="1")] _1 = 1, [System.Runtime.Serialization.EnumMemberAttribute(Value="2")] _2 = 2, [System.Runtime.Serialization.EnumMemberAttribute(Value="3")] _3 = 3, }
If I remove the Value from [EnumMember(Value = "1")], while deserialization is considering Enum Text, and giving results as below
<AppointmentMode>None</AppointmentMode>
Expected result:
1. Enum in the Client proxy should be same original Enum.
2. Enum Deserialization should consider EnumValue, such a way that it will return
<AppointmentMode>1</AppointmentMode>
How to get this done?
View 5 Replies
Oct 13, 2010
Type 'System.Data.Linq.ChangeTracker+StandardChangeTracker' in Assembly 'System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable
have read all threads but still cant solve the error. I can do insert update and delete but dont know where exactly the error occurs and how??
View 1 Replies
Oct 21, 2010
i need to serialize and deserialize an image for my project. i have been googling it for a few days but i cannot find any VB codes related to image serialization... can someone give me some hints on how i should start?? for my program, i need to save the image to sql database and then i need to retrieve all the image for my product catalog
View 2 Replies
Jan 21, 2011
Currently I am working on SessionState with SQL. I have problem. I would like to serialize TreeNode. This TreeNode pbject will be assigned to Session and this is declare as below.
private _treeNode as TreeNode <-- member variable
how do I make this _treeNode seriablizable?
View 1 Replies
Jul 2, 2010
Is there any way or process to serialize the the objects?? i am trying to store the instance of few control in viewstate but it shows error msg that it is not a serialized object. should i perform some steps to serialize the objects ???
View 9 Replies
Feb 3, 2011
How do I get at the data after doing a .sortable serialize? Here is my code :
[Code]....
View 1 Replies
May 18, 2010
I am facing the problem while using For Xml'AddressLine' because it contains a character (0x000F) which is not allowed in XML I found some other similar charectors which is raising the exception.Using replace of such charectors results in loss of data Please give me a solution or any work around.
View 2 Replies
Apr 14, 2010
Using the following code:
Private Sub MakeMeSomeXmlBeforeRyanGetsAngry()
Dim db As New MyDBDataContext
Dim customer = From c In db.Customers Select c
Dim dcs As New DataContractSerializer(GetType(Customer))
Dim sb As StringBuilder = New StringBuilder
Dim writer As XmlWriter = XmlWriter.Create(sb)
dcs.WriteObject(writer, customer)
Dim xml As String = sb.ToString
Response.Write(xml)
End Sub
I am attempting to serialize my linq collection of customers. But it keeps throwing
Type 'System.Data.Linq.DataQuery`1[MyDB.Customer]' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. See the Microsoft .NET Framework documentation for other supported types.
My issue is that I have already marked the dbml Serialization Mode to UniDirectional and when I check the dbml codebehind all of the DataContract()> and DataMember()> elements are there.
I am not sure how to proceed. I have tried adding various dataloadoptions and setting deferredloading to false, but no luck.
View 2 Replies
Sep 9, 2010
I am using Flexigrid in my project to add a button on the grid toolbar I can use code like this:
"buttons":[
{"name":"Modifica","bclass":"edit","onpress":"doCommand"},
{"name":"Elimina","bclass":"delete","onpress":"doCommand"}
],
Anyway the "onpress" attribute shall contain a reference to a js callback and so this field shall not be enclosed within quotation marks.
I am using the class JavaScriptSerializer (in the System.Web.Script.Serialization namespace) to do the serialization.
How I have to declare the variable to make JavaScriptSerializer serialize like this?
"buttons":[
{"name":"Modifica","bclass":"edit","onpress":doCommand},
{"name":"Elimina","bclass":"delete","onpress":doCommand}
],
View 3 Replies
Oct 1, 2010
I have a custom Javascript object that has a few string and float members. I'd like to serialize an array of them in Javascript, assign the result to a hidden field, and then retrieve and deserialize them in the codebehind for my asp.net application.
View 3 Replies
Mar 16, 2010
I am trying to serialize an object that has a public member of type ArrayList. If I am reading
this correctly, an ArrayList is a serializeable member. My class looks like this:
[DataContract(Name="Family")]
public class Family
{
private int _FamilyID;
[DataMember]
[Code]....
But then I'm serializing more of the properties than I want. I would be happy to either a) figure out how to get DataContractJsonSerializer to serialize my ArrayList or b) get JavaScriptSerializer to have the effect of honoring a datacontract. I understand that JavaScriptSerializer is depricated so I suppose DataContractJsonSerializer is the way to go if possible.
View 3 Replies
Dec 11, 2013
Getting error when trying to save structured arraylist into session Variable (see btnTS_Click below)
Code works on my desktop VS2012 devel system but not when posted to webserver we use.
Try It: [URL] ....
Code:
Public Class _Default
Inherits System.Web.UI.Page
Structure HoursData
Dim Project As String
[Code]...
View 9 Replies