Sunday, April 18, 2010

How to Use Google Search In Asp.net

How to Use Google Search In Asp.net

To Use google Search In Your Application

First Take One Seach Page And Button

And Craete HTML Page "Search.aspx" and Use Below Code In It
[form id="formsearch? runat="server"]

[div]

[asp:Label ID="lblsearch" runat="server" Width="120px"]Google Search…[/asp:Label][br /]

[asp:Label ID="lblmsg? runat="server" ][/asp:Label]


[asp:TextBox ID="txtseach" runat="server" Height="19px" Width="293px" ][/asp:TextBox]

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

[/div]

[/form]



Write Below Code In Btn Event Of btnSearch in search.aspx.cs
protected void  btnsearch_Click(object sender, EventArgs e)
{
if (txtseach.Text.Trim().Length == 0)
{
lblmsg.Text = "Please enter text to search";
}
else
{
Response.Redirect("http://www.google.com/search?q=" + txtseach.Text);
}
}


Action Method in Mvc

In this section, you will learn about the action method of controller class. All the public methods of a Controller class are called Act...