w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
C# json serialization and deserialization without attributes

yes it is possible, i'll give you an example by writing asp.net code ::

c# code:

public class a{
    public prop int id
}

public class b: public a{
    public prop string name 
}

asp.net code:

@model b    // for taking b as model in this view

<form action="action" method="post" id="myForm">
    enter id : @Html.TextboxFor(m=>m.id)
    enter name : @Html.TextboxFor(m=>m.name)
<input type="submit" id="send" value="submit">
</form>

jquery code:

$("#send").click(function(e)){
    e.preventDefault();
    $.ajax({
    url:"myURL",
    data: $("#myForm").serialize(),     // for serialization of whole form
or object b
    success: function(result){},
    }

So here the line [data: $("#myForm").serialize()] serialize the whole object b or form "myForm". Here no need to serialize specific attributes. Hope this helps





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.