.

DynamicJsonConverter : JavaScriptConverter

    public sealed class DynamicJsonConverter :  JavaScriptConverter
    {
        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            if (dictionary == null)
                throw new ArgumentNullException("dictionary");

            return type == typeof(object) ? new DynamicJsonObject(dictionary) : null;
        }

        public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            throw new NotImplementedException();
        }

        public override IEnumerable<Type> SupportedTypes
        {
            get { return new ReadOnlyCollection<Type>(new List<Type>(new[] { typeof(object) })); }
        }

        #region Nested type: DynamicJsonObject

        private sealed class DynamicJsonObject : DynamicObject
        {
            private readonly IDictionary<string, object> _dictionary;

            public DynamicJsonObject(IDictionary<string, object> dictionary)
            {
                if (dictionary == null)
                    throw new ArgumentNullException("dictionary");
                _dictionary = dictionary;
            }

            public override string ToString()
            {
                var sb = new StringBuilder("{");
                ToString(sb);
                return sb.ToString();
            }

            private void ToString(StringBuilder sb)
            {
                var firstInDictionary = true;
                foreach (var pair in _dictionary)
                {
                    if (!firstInDictionary)
                        sb.Append(",");
                    firstInDictionary = false;
                    var value = pair.Value;
                    var name = pair.Key;
                    if (value is string)
                    {
                        sb.AppendFormat("{0}:\"{1}\"", name, value);
                    }
                    else if (value is IDictionary<string, object>)
                    {
                        new DynamicJsonObject((IDictionary<string, object>)value).ToString(sb);
                    }
                    else if (value is ArrayList)
                    {
                        sb.Append(name + ":[");
                        var firstInArray = true;
                        foreach (var arrayValue in (ArrayList)value)
                        {
                            if (!firstInArray)
                                sb.Append(",");
                            firstInArray = false;
                            if (arrayValue is IDictionary<string, object>)
                                new DynamicJsonObject((IDictionary<string, object>)arrayValue).ToString(sb);
                            else if (arrayValue is string)
                                sb.AppendFormat("\"{0}\"", arrayValue);
                            else
                                sb.AppendFormat("{0}", arrayValue);

                        }
                        sb.Append("]");
                    }
                    else
                    {
                        sb.AppendFormat("{0}:{1}", name, value);
                    }
                }
                sb.Append("}");
            }

            public override bool TryGetMember(GetMemberBinder binder, out object result)
            {
                if (!_dictionary.TryGetValue(binder.Name, out result))
                {
                    // return null to avoid exception.  caller can check for null this way...
                    result = null;
                    return true;
                }

                var dictionary = result as IDictionary<string, object>;
                if (dictionary != null)
                {
                    result = new DynamicJsonObject(dictionary);
                    return true;
                }

                var arrayList = result as ArrayList;
                if (arrayList != null && arrayList.Count > 0)
                {
                    if (arrayList[0] is IDictionary<string, object>)
                        result = new List<object>(arrayList.Cast<IDictionary<string, object>>().Select(x => new DynamicJsonObject(x)));
                    else
                        result = new List<object>(arrayList.Cast<object>());
                }

                return true;
            }
        }

        #endregion
    }

 

 

 

 

 

    public class Json
    {
        public static dynamic DeserializeMemorySteamToObject(HttpRequestBase request)
        {
            var json = string.Empty;
            using (var reqMemStream = new StreamReader(request.InputStream))
            {
                json = reqMemStream.ReadToEnd();
            }

            var serializer = new JavaScriptSerializer();
            serializer.RegisterConverters(new[] { new DynamicJsonConverter() });
            return (dynamic)serializer.Deserialize(json, typeof(object));
        }

    }
        [HttpPost]
        public ActionResult UpdatePatientDetails()
        {
            var obj = PasPlus.Core.Json.DeserializeMemorySteamToObject(Request);

            var patientId = obj.patientId;
            var patient = new PasPlus.BusinessObjects.Core.Patients(patientId.ToString());

            patient.Surname = obj.surname;
            patient.Forname = obj.forname;
            patient.Other_names = obj.otherNames;
            patient.Postcode = obj.postcode;
            patient.Telephone_home = obj.telephoneHome;
            patient.Telephone_mobile = obj.telephoneMobile;
            patient.Telephone_work = obj.telephoneWork;
            patient.Email = obj.email;
            patient.Next_of_kin = obj.nextOfKin;
            patient.Next_of_kin_tel = obj.nextOfKinPhone;

            patient.Save();
            return null;
        }
<script type="text/javascript">
    $(document).ready(function () {
        //set date format of date picker string
        $(function () {
            $("#dobTextBox").datepicker({ dateFormat: 'dd/mm/yy' });
        });

        $('#CloseButton').click(function (index) {
            $('#dialogBox').dialog('destroy').remove();
        });

        $("#SaveButton").click(function () {
            //create json 
            var patientId = $('#patientIdHiddenField').val();
            var surname = $('#surnameTextBox').val();
            var forname = $('#fornameTextBox').val();
            var otherNames = $('#otherNamesTextBox').val();
            var postcode = $('#postcodeTextBox').val();
            var telephoneHome = $('#telephoneHomeTextBox').val();
            var telephoneMobile = $('#telephoneMobileTextBox').val();
            var telephoneWork = $('#telephoneWorkTextBox').val();
            var email = $('#emailTextBox').val();
            var nextOfKin = $('#nextOfKinTextBox').val();
            var nextOfKinPhone = $('#nextOfKinPhoneTextBox').val();

            var json = JSON.stringify({
                patientId: patientId,
                surname: surname,
                forname: forname,
                otherNames: otherNames,
                postcode: postcode,
                telephoneHome: telephoneHome,
                telephoneMobile: telephoneMobile,
                telephoneWork: telephoneWork,
                email: email,
                nextOfKin: nextOfKin,
                nextOfKinPhone: nextOfKinPhone
            });

            var uri = '../los/Update/UpdatePatientDetails/';

            $('#dialogBox').empty().dialog('destroy');

            $.post(uri, json, function () {
                $(window.location.reload());
                //callback function for success
            });

            $(window.location.reload());
        });
    });
</script>

iis 7 mvc

HTTP Error 403.14 – Forbidden The Web server is configured to not list the contents of this directory. Detailed

 

ASP.NET 4 was not registered in IIS. Had to run the following command in the command line/run

32bit (x86) Windows

%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -ir

64bit (x64) Windows

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir

Note from David Murdoch’s comment:

That the .net version has changed since this Answer was posted. Check which version of the framework is in the %windir%\Microsoft.NET\Framework64 directory and change the command accordingly before running (it is currently v4.0.30319)

mvc installation – not supported by this installation

run this installation:

http://www.microsoft.com/en-us/download/details.aspx?id=4211

 

make a namespace global to all forms

In your web.config file:

 

<pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages"/>
      </namespaces>
    </pages>
  </system.web>

ispostback vs iscallback

Page.IsCallBack

It is getting a value indicating whether the page request is the result of a call back. Its a special postback, so a round-trip always occurs; however, unlike the classic postback, the script callback doesn’t redraw the whole page. ViewState is not updated during a callback, it is for postback.

Page.IsPostBack

Checks whether the Page is accessing the server for the first time or not. Unlike the IsCallBack, the ViewState is updated

Refer to Page Life Cycle for more detail that shows a diagram illustrating the sequence of events

Edit - To answer your new question

Page.IsPostback property will return true for both request types. The Page.IsCallback property will return true only when the request is a client callback