Skip to main content

Posts

Showing posts from December, 2011

jQuery Fiddles

The following are js fiddles 1. For demo on how to append an option tag between another option tag dynamically using jquery link 2. A demo of sortables using jQuery UI [1.7.2] and jQuery [1.3.2] link 3. The following JS fiddle is used to check how the value of an emtpy text box is recevied at Javascript link

jQuery Tips

The following are useful tips for handling jQuery - Javascript library 1. To change the selected option based on the option tag's value , use the following code. $('#element option[value="no"]').attr("selected", "selected"); However, if multiple options can be selected, first deselect them using the following code HTML MarkUp Default Selection 1 Selection 2 -- Javascript with jQuery -- $("document").ready(function() { $("#b1").click(function() { $(".selDiv select.opts option").each(function() { $(this).removeAttr("selected"); }); var optSelValue = $("#txt").val(); $(".selDiv select.opts option[value=\"" + optSelValue + "\"]").attr("selected", "selected"); }); }); Full Sample

WebService Bug & Resolution

The following bug is encountered when running a webservice on a newly installed windows machine with new IIS [7] Bug: [NullReferenceException: Object reference not set to an instance of an object.] System.Web.Security.RoleManagerModule.OnEnter(Object source, EventArgs eventArgs) +313 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +102 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75 Solution : Go to Control Panel > Turn on or off windows features > roles > ASP.NET > if not installed, click on the Add Role Features > select ASP.NET > Finish Installation and restart website / webservice.

C# Serialization

To use the XML Serializer in C#.NET, use as follows public static class SerializationHelper { /// /// Serializes the object and returns the serialized object's xml string /// /// The obj. /// public static string SerializeObject(Object obj) { var xmlSerializer = new System.Xml.Serialization.XmlSerializer(obj.GetType()); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); xmlSerializer.Serialize(memoryStream, obj); memoryStream.Seek(0, System.IO.SeekOrigin.Begin); return new System.IO.StreamReader(memoryStream).ReadToEnd(); } /// /// Desserializeobjs the specified object XML string. /// /// /// The object XML string. /// public static object DeSerializeObject (string objectXmlString) { var xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(T)); using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream()) { using (System.IO.StreamWriter swr = new System.IO.StreamWriter(memoryStream))