Wednesday, January 8, 2014
How to solve "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property"?
The default value for JavaScriptSerializer is 102400. Need to change before using:
JavaScriptSerializer serializer = new JavaScriptSerializer();
serializer.MaxJsonLength = int.MaxValue;
Reference:
http://msdn.microsoft.com/en-us/library/system.web.configuration.scriptingjsonserializationsection.maxjsonlength.aspx
Tuesday, January 7, 2014
How to solve problem "This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet"?
public ActionResult JsonRequest()
{
return Json(instanceOfClass, JsonRequestBehavior.AllowGet);
}
Monday, January 6, 2014
How to solve problem: tinymce steal focus in ie?
setup : function(ed) {
ed.onLoadContent.add(function(ed, o) {
var controlLoad = setTimeout(function() {
if ($('.mceIframeContainer').size()==1) {
$('form *:input[type!=hidden]:first').focus();
clearTimeout(controlLoad);
}
}, 100);
});
}
Code and working example link:http://dl.dropboxusercontent.com/u/76169930/stackoverflow/question/10944450/tinymce/examples/no_contents_inside_textarea.html
Reference:
http://stackoverflow.com/questions/10944450/is-there-a-way-to-prevent-tinymce-from-auto-focusing-on-page-load
How to set default value for Auto-Implemented Properties in C#
Auto-Implemented Properties:
public string Name { get; set; }
Not you can not modify property directly, you could put default in class constructor.
public string Name { get; set; }
Not you can not modify property directly, you could put default in class constructor.
Friday, January 3, 2014
How to deserialize json data into dynamic object in C#?
Get DynamicJsonConverter code from
https://github.com/tomvdb/coderwall-csharp-wrapper/blob/master/coderwall_api/DynamicJsonConverter.cs
https://github.com/tomvdb/coderwall-csharp-wrapper/blob/master/coderwall_api/DynamicJsonConverter.cs
string JSONdata ="";
var serializer = new JavaScriptSerializer();
serializer.RegisterConverters(new[] { new DynamicJsonConverter() });
dynamic obj = serializer.Deserialize(JSONdata, typeof(object));
Subscribe to:
Posts (Atom)