Google Search from ASP.NET

Google Search from ASP.NET

Here by this article we will learn how to search on google based on the query write in textbox

Here is a textbox and a button, write your search text in textbox and click the button, the button redirect you to google with the search result written in textbox…



<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">


<html xmlns="" >

<head runat="server">

    <title>Google Search</title>



    <form id="form1" runat="server">


    <asp:Label ID="lbl" runat="server" Width="120px">Google Search...</asp:Label><br />

        <asp:Label ID="Label1" runat="server" ForeColor="Red" Style="z-index: 100; left: 14px;

            position: absolute; top: 95px"></asp:Label>

    <br />

    <asp:TextBox ID="txt" runat="server" Height="19px" Width="293px" ></asp:TextBox>

    <asp:Button ID="btnsearch" runat="server" Text="Search Google" Height="25px" OnClick="btnsearch_Click" Width="137px" />







using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;


public partial class _Default : System.Web.UI.Page


    protected void Page_Load(object sender, EventArgs e)




    protected void btnsearch_Click(object sender, EventArgs e)


        if (txt.Text.Trim().Length == 0)


            Label1.Text = "Please enter text to search";




            Response.Redirect("" + txt.Text);