Posts

Showing posts from April, 2012
Call Asp.net Page Method Using Jquery  <html> <head runat="server">     <title>Ajax Page</title>     <script type="text/javascript" src="../Library/jquery-1.6.2.min.js"></script>     <script type="text/javascript" language="javascript">          function CalllPageMethod() { // this will be called on button click event                $.ajax({                 type: "POST",                 url: "Default.aspx/" + "GetData" , // Default.page is your page and GetData is Your public Method inside code behind file which will return some response.                 data: "{'FirstName': '"+$("input#txtFirstName").val()+"'} ",// Here i am passing the value of txtFirstname to GetData method //FirstName is parameter of GetData method                 contentType: "application/json; charset=utf-8" ,        
Dynamically change the value of public variable using reflection in c# Once i was working on asp.net project and i got a little task that i need to change the values of Blank public variables, i was having two way of doing this one was to set each variable value manually or other is by using reflection, i did little Google, and then created a method that replace the value of each public variable of type string. //this1 is the any class object and you want to replace the values of public string variables of this object public void ReplaceBlankValues(object this1) {   //MemberInfo  array will hold all public variables of class    MemberInfo[] properties = this1.GetType().GetMembers(BindingFlags.Public | BindingFlags.Instance);             foreach (var property in properties)             {                 if (property.ToString().Length > 13)                 {                     string type = property.ToString().Substring(0, 13);                     if (type == &quo
Call Asp.net Page Method Without Microsoft Ajax, without j query Have you ever thought that we can call the web method without using j query, or Microsoft Ajax, This tutorial will help you lot to understand the Ajax in asp.net Default.aspx             <button onclick="javascript:callWebMethod();">             GetName</button> This button will call the callWebMethod() javascript method Default.aspx.cs Lets call GetName method using javascript       //I will call this method from client code using java script       [WebMethod]         public static string GetName(string name)         {             return "Hello " + name;         }  Javascript Code //name is the parameter in GetName Web method //vijay is the parameter value  var data = '{"name":"vijay"}';   // I will call this method on above button click event function callWebMethod() {     var xmlhttp = createXMLHTTPObject();     xmlhttp.onreadysta