Monday, January 23, 2012

How do I remove my personal details from Google search?

If you want to remove your personal details/data from google search results try use some of these tools:
1. Wizard Removing Content From Google
2. Keeping personal information out of Google.
3. User Webmaster Tools for remove data:

If you don’t already have one, then
1) Create a Google account (I am sure you might have one, if not create a gmail account)
2) Go to this URL: https://www.google.com/webmasters/tools/removals



3) Click on "Create a new removal request" button
4) Type in URL you would like to remove.
That's it you are done.

Saturday, January 21, 2012

JQuery Ajax DB Call to Retrieve data based on user Criteria

In this article, i will be retrieving data from database with asp.net web service using jQuery Ajax.

If you are new to jQuery and don't know anything about it, I will recommend you to first read following articles before reading any further.


In this article we will take input country name and display region information. Check out Live Demo

Step 1: Create Asp.net Web Application


Step 2: Open Site.Master and include jQuery Reference by adding below line just before </head> tag.
<!--Include JQuery File-->
<script type="text/javascript" language="Javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>




Step 3: Open "Default.aspx" and add following code
I have added here h2 title tag, asp.net button, textbox and label.  Please note, that i have declared ShowRegionInfo function, I will be calling javascript this function, which will internally make jQuery Ajax call to asp.net web service.



<h2>Example 4: JQuery DB Call to Retrieve data based on user Criteria </h2>
<br />
<b>Retrieve region based on country name</b><br /><br />
Enter Country Name: <asp:TextBox ID="txtCountryName" runat="server" Text=""></asp:TextBox><br />
<asp:Button ID="btnGetMsg" runat="server" Text="Click Me" OnClientClick="ShowRegionsInfo();return false;" /><br />
<asp:Label ID="lblOutput" runat="server" Text=""></asp:Label>


Step 4: Add new folder to solution named "WebService"


Step 5: Right click on "WebService" folder and click add new item, to add new web service.


Step 6: Add code to make database call to retrieve region data using jQuery Ajax.  Please add following code inside "wsJQueryDBCall.asmx.cs" file
Add following namespaces

using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using System.Text;


Add following code



[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class wsJQueryDBCall : System.Web.Services.WebService
{


    [WebMethod]
    public string ReadRegion(string CountryName)
    {
        String strConnString = ConfigurationManager.AppSettings["connStr"].ToString();


        String strQuery = "Select Region " +
                            "from Regions " +
                            "Inner Join CountriesNew on CountriesNew.CountryId = Regions.CountryId " +
                            "where UPPER(CountriesNew.Country) = @CountryName";


        using (SqlConnection con = new SqlConnection(strConnString))
        {
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@CountryName", CountryName.ToUpper());
                cmd.CommandText = strQuery;
                cmd.Connection = con;
                con.Open();
                SqlDataReader sdr = cmd.ExecuteReader();
                StringBuilder sb = new StringBuilder();


                if (sdr.HasRows)
                {
                    sb.Append("" + CountryName + " has following regions:
");



                    while (sdr.Read())
                    {
                        sb.Append(sdr["Region"].ToString() + "
");

                    }
                }
                else
                {
                    sb.Append("No Records found");
                }


                con.Close();


                return sb.ToString();
            }
        }
    }
}

As you have noticed ReadRegion Method is regular method which takes input country name and makes database call to retrieve region data from sql server database and return result as appended string of region.


Important Note:  Please UnComment line
[System.Web.Script.Services.ScriptService]
In order to allow this Web Service to be called from script, using ASP.NET AJAX



Step 7:  Open "Default.aspx" and Write jQuery function to make webservice call to retrieve data from database.



<script type = "text/javascript">
    function ShowRegionsInfo() {


        var pageUrl = '<%=ResolveUrl("~/WebService/wsJQueryDBCall.asmx")%>'
            
        $.ajax({
            type: "POST",
            url: pageUrl + "/ReadRegion",
            data: "{'CountryName':'" + $('#<%=txtCountryName.ClientID%>').val() + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: OnSuccessCall,
            error: OnErrorCall
        });


    }


    function OnSuccessCall(response) {
        $('#<%=lblOutput.ClientID%>').html(response.d);
    }


    function OnErrorCall(response) {
        alert(response.status + " " + response.statusText);
    }
</script>


Understanding jQuery Ajax call parameter

Now, run the web application and input your country name and hit button to see region which is retrieved from sql server database.


Check out Live Demo of Calling Webservice using JQuery Ajax Example

More JQuery Tutorials

JQuery Ajax Examples by calling asp.net webservice

In this article, i will be calling asp.net web service using jQuery Ajax.

With JQuery Ajax you can do

  • Make a database call and perform CRUD operation (Create, Read, Update and Delete) without page postback
  • If you have used Ajax Control Toolkit in past then you will be able to do almost all such operations and lot more by using jQuery Ajax and JQuery UI.

If you are new to jQuery and don't know anything about it, I will recommend you to first read following article before reading any further.

OK, so lets start the real fun

Since it is our first example, lets keep it simple and display "Hello World". Check out Live Demo

Step 1: Create Asp.net Web Application


Step 2: Open Site.Master and include jQuery Reference by adding below line just before </head> tag.
<!--Include JQuery File-->
<script type="text/javascript" language="Javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>




Step 3: Open "Default.aspx" and add following code
I have added here h2 title tag, asp.net button and label.  Please note, that i have declared OnClientClick, I will be calling javascript function, which will internally make jQuery Ajax call to asp.net web service.
<h2>Example 1: Call Webservice using JQuery AJax (Without Input)</h2>


<asp:Button ID="btnGetMsg" runat="server" Text="Click Me" OnClientClick="DisplayMessageCall();return false;" /><br />


<asp:Label ID="lblOutput" runat="server" Text=""></asp:Label>


Step 4: Add new folder to solution named "WebService"


Step 5: Right click on "WebService" folder and click add new item, to add new web service.


Step 6: Add code to display message inside "HelloWorld.asmx.cs" file
///
/// Summary description for HelloWorld
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class HelloWorld : System.Web.Services.WebService
{
    [WebMethod]
    public string DisplayMessage()
    {
        return "Hello World using jQuery Ajax";
    }
}
Important Note:  Please UnComment line
[System.Web.Script.Services.ScriptService]
In order to allow this Web Service to be called from script, using ASP.NET AJAX



Step 7:  Open "Default.aspx" and Write jQuery function to make webservice call to display "Hello World" message.
<script type = "text/javascript">
    function DisplayMessageCall() {


        var pageUrl = '<%=ResolveUrl("~/WebService/HelloWorld.asmx")%>'


        $.ajax({
            type: "POST",
            url: pageUrl + "/DisplayMessage",
            data: '{}',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: OnSuccessCall,
            error: OnErrorCall
        });


    }


    function OnSuccessCall(response) {
        $('#<%=lblOutput.ClientID%>').html(response.d);
    }


    function OnErrorCall(response) {
        alert(response.status + " " + response.statusText);
    }
</script>

Understanding jQuery Ajax call parameter
  • type: Can be POST or GET.
  • url: Path of webservice file (Example here: path of HelloWorld.asmx file) In the above code you can find that i have declare path of webservice in pageurl variable.  Since we are going to call "DisplayMessage" method name inside webservice we have write pageUrl + "/DisplayMessage"  (i.e. Webservice Path + Method Name)
  • data: In this example the data will remain empty, as we are only calling a method which return a simple string and don’t accept any parameter. If the method has some parameters then we will pass the parameters. I will explain on passing parameters in my coming posts.
  • contentType: Should remain the same.
  • datatype: Should remain as it is.
  • success: Here I have called the OnSuccessCall when the call is complete successfully. If you check the OnSuccessCall method you will see that I have set the returned result from the web service to the label. In the OnSuccessCall method body you see ‘data.d’. The ‘d’ here is the short form of data.
  • Error: Same as I have done with OnSuccessCall. If any error occurred while retrieving the data then the OnErrorCall method is invoked.
Now, run the web application and hit button to see message.

Check out Live Demo of Calling Webservice using JQuery Ajax Example

Note: Please remember, JQuery is Javascript library so you will NOT be able to retrieve large amount of data or do heavy database operations.  Example: If you want to load 7000 Records from database then JQuery Ajax is not good approach.  To best of my knowledge you will never run into such situation except loading cascading dropdown, incase you run in any such situation than you should rethink your approach.

Friday, January 20, 2012

jQuery Ajax Example - Call Webservice using JQuery AJax (With Multiple Input)

In this article, i will be calling asp.net web service using jQuery Ajax with Multiple Input parameter.

If you are new to jQuery and don't know anything about it, I will recommend you to first read following article before reading any further.


In this article we will take input name and location and display greeting message. I will be also adding small delay to create Ajaxify effect.  Check out Live Demo

Step 1: Create Asp.net Web Application


Step 2: Open Site.Master and include jQuery Reference by adding below line just before </head> tag.
<!--Include JQuery File-->
<script type="text/javascript" language="Javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>




Step 3: Open "Default.aspx" and add following code
I have added here h2 title tag, asp.net button, textbox and label.  Please note, that i have declared OnClientClick, I will be calling javascript function, which will internally make jQuery Ajax call to asp.net web service.


<h2>Example 3: Call Webservice using JQuery AJax (With Multiple Input)</h2>
Enter your Name: <asp:TextBox ID="txtName" runat="server" Text=""></asp:TextBox><br />
Enter Location: <asp:TextBox ID="txtLocation" runat="server" Text=""></asp:TextBox><br />
<asp:Button ID="btnGetMsg" runat="server" Text="Click Me" OnClientClick="DisplayMessageCall();return false;" /><br />
<asp:Label ID="lblOutput" runat="server" Text=""></asp:Label>


Step 4: Add new folder to solution named "WebService"


Step 5: Right click on "WebService" folder and click add new item, to add new web service.


Step 6: Add code to display message inside "HelloWorld.asmx.cs" file


[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class HelloWorld : System.Web.Services.WebService
{


    [WebMethod]
    public string DisplayMessage(string NameInfo, string Location)
    {
        //Creating Delay
        System.Threading.Thread.Sleep(1000);
        return "Welcome " + NameInfo + ", Your location is " + Location;
    }
}

Important Note:  Please UnComment line
[System.Web.Script.Services.ScriptService]
In order to allow this Web Service to be called from script, using ASP.NET AJAX



Step 7:  Open "Default.aspx" and Write jQuery function to make webservice call to display greeting message.


<script type = "text/javascript">
    function DisplayMessageCall() {


        var pageUrl = '<%=ResolveUrl("~/WebService/HelloWorld.asmx")%>'


        $('#<%=lblOutput.ClientID%>').html('Please wait...');


        $.ajax({
            type: "POST",
            url: pageUrl + "/DisplayMessage",
            data: "{'NameInfo':'" + $('#<%=txtName.ClientID%>').val()
                    + "','Location':'" + $('#<%=txtLocation.ClientID%>').val() + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: OnSuccessCall,
            error: OnErrorCall
        });


    }


    function OnSuccessCall(response) {
        $('#<%=lblOutput.ClientID%>').html(response.d);
    }


    function OnErrorCall(response) {
        alert(response.status + " " + response.statusText);
    }
</script>

In above code before calling webservice i have assign "Please wait..." to output label.


Understanding jQuery Ajax call parameter

Now, run the web application and input your name and hit button to see greeting message.

You might notice that code will cause small delay, it will show "Please wait..." message while it is causing delay.



Check out Live Demo of Calling Webservice using JQuery Ajax Example

More JQuery Tutorials

jQuery Ajax Example - Call Webservice using JQuery AJax (With Input)

In this article, i will be calling asp.net web service using jQuery Ajax with Input parameter.

If you are new to jQuery and don't know anything about it, I will recommend you to first read following article before reading any further.


In this article we will take input name and display greeting message. Check out Live Demo

Step 1: Create Asp.net Web Application


Step 2: Open Site.Master and include jQuery Reference by adding below line just before </head> tag.
<!--Include JQuery File-->
<script type="text/javascript" language="Javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>




Step 3: Open "Default.aspx" and add following code
I have added here h2 title tag, asp.net button, textbox and label.  Please note, that i have declared OnClientClick, I will be calling javascript function, which will internally make jQuery Ajax call to asp.net web service.

<h2>Example 2: Call Webservice using JQuery AJax (With Input)</h2>
<asp:TextBox ID="txtName" runat="server" Text="Enter your name"></asp:TextBox>
<asp:Button ID="btnGetMsg" runat="server" Text="Click Me" OnClientClick="DisplayMessageCall();return false;" /><br />
<asp:Label ID="lblOutput" runat="server" Text=""></asp:Label>


Step 4: Add new folder to solution named "WebService"


Step 5: Right click on "WebService" folder and click add new item, to add new web service.


Step 6: Add code to display message inside "HelloWorld.asmx.cs" file

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class HelloWorld : System.Web.Services.WebService
{


    [WebMethod]
    public string DisplayMessage(string NameInfo)
    {
        return "Welcome " + NameInfo + " to the world of JQuery AJax";
    }
}

Important Note:  Please UnComment line
[System.Web.Script.Services.ScriptService]
In order to allow this Web Service to be called from script, using ASP.NET AJAX



Step 7:  Open "Default.aspx" and Write jQuery function to make webservice call to display greeting message.

<script type = "text/javascript">
    function DisplayMessageCall() {


        var pageUrl = '<%=ResolveUrl("~/WebService/HelloWorld.asmx")%>'


        $.ajax({
            type: "POST",
            url: pageUrl + "/DisplayMessage",
            data: "{'NameInfo':'" + $('#<%=txtName.ClientID%>').val() + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: OnSuccessCall,
            error: OnErrorCall
        });


    }


    function OnSuccessCall(response) {
        $('#<%=lblOutput.ClientID%>').html(response.d);
    }


    function OnErrorCall(response) {
        alert(response.status + " " + response.statusText);
    }
</script>

Understanding jQuery Ajax call parameter

Now, run the web application and input your name and hit button to see greeting message.


Check out Live Demo of Calling Webservice using JQuery Ajax Example

More JQuery Tutorials

Most Recent Post

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape