Posts

Showing posts from 2012

Phone Number Auto Increment Decrement Focus

Following Jquery functions are used to set focus on text box on max length and set focus to prev text box on click of backspace when length gets zero. $(function () { $('.phoneText,.AlternatePhoneText,.FaxText').keyup(function (e) { if (e.which == 8) { if ($(this).val().length == 0)  $(this).prev(':input').focus(); } else { if ($(this).val().length == $(this).attr('maxlength'))  $(this).next(':input').focus(); } }) })  

SetProperty and GetProperty with C# Reflection

SetProperty and GetProperty with C# Reflection   private object getProperty ( object containingObject, string propertyName ) { return containingObject. GetType ( ) . InvokeMember ( propertyName, BindingFlags. GetProperty , null , containingObject, null ) ; } private void setProperty ( object containingObject, string propertyName, object newValue ) { containingObject. GetType ( ) . InvokeMember ( propertyName, BindingFlags. SetProperty , null , containingObject, new object [ ] { newValue } ) ; }

Receive Json Web response in C#

Following code use to get Json Response in My object using (var twitpicResponse = (HttpWebResponse)request.GetResponse()) {         using (var reader = new StreamReader(twitpicResponse.GetResponseStream())) {             JavaScriptSerializer js = new JavaScriptSerializer();             var objText = reader.ReadToEnd();             MyObject myojb = (MyObject)js.Deserialize(objText,typeof(MyObject));         }     }