Saturday, 28 February 2015

read json in c#

Reading the JSON file passing from Jscript file and read that in C# Code

Suppose you are creating the JSON file like below;

function GetInsertedData() {
    var CustomerDetailsModels = {
        CustomerDetailId: $("#hdnId").val(),
        ClinicName: $("#txtClinicName").val(),
       PhoneNumber: $("#txtPhoneNumber").val(),
        UserName: $("#txtUserName").val(),
        Password: $("#txtPassword").val(),
        // DateOfRegistration: $("#DateOfRegistration").val(),
        ValidaityDate: $("#txtValidaityDate").val(),
        ActiveDate: $("#txtDateOfActivation").val(),
        Address1: $("#txtAddress1").val(),

        Address2: $("#txtAddress2").val(),
        CountryId: $("#ddlSelecteCountry").val(),
        StateId: $("#ddlSelectState").val(),
        DisctrictId: $("#ddlDistrict").val(),
        PinCode: $("#txtPincode").val(),
        EmailId: $("#txtEmailID").val(),
        Website: $("#txtWebsite").val(),
        OfficeNumber: $("#txtOfficeNumber").val(),
        NumberOfUser: $("#ddlAllowedNumberUser").val(),
        IsActive: $("#chkISActive").val(),
        IsPaid: $("#chkISPaid").val(),
        AmountPaid: $("#txtPaidAmount").val()

how to read class property name in c#

Dynamically retrieve and save property name and value into the database That can be possible if you are able to read the class property dynamically, and later on retrieve it from the database and invoke the property values

If you have already get work done that how to save the property name in the database, then use Get Property is the way to go on the retrieval of property.

Use Gettype to get the class types. 

Others

You will like to read it