PM's Blog

Pramod Mohanan's notes about ASP.NET, MVC, C#, SQL, jQuery, Bootstrap

Month – December 2011

Avoid Redirect to Login Page

When the following authorization is set in the config file at the site’s root, inside the system.web node, we notice that no object is rendered unless the user gets authenticated. This also includes images, style sheets, javascripts etc. <authorization>     <deny users="?" />     <allow users="*" /> </authorization> In cases like these, we […]

Cross Domain Ajax using jQuery

Browsers by default don’t allow cross domain ajax. Conceptually we can implement JSONP (see http://en.wikipedia.org/wiki/JSONP) using jquery to do this. Here is an example <script type="text/javascript"> $(document).ready(function () {    var s = $.ajax({ url: "http://someotherdomain.com/page?callback=?", context: document.body, dataType: "jsonp" }); }); function populate(data) {   $(".info").html(unescape(data)); } </script> <button id="btn" value="click me" /> <div […]

Loop through properties of an object

I just had a need to loop through all the properties of an object and copy the values of the properties to another object of the same type. I just discovered that we can use System.Relection to get this done. For example two objects sourceObject and destinationObject are objects of class Person. using System.Reflection; namespace […]

PM's Blog © 2015