C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

Google Web API


Posted Date: 19 Aug 2008      Posted By: Murugan      Member Level: Bronze     Points: 1   Responses: 4



Hi friends,

I have a web Page , i want to include the google search in my page.
Can u tell me it in step by step?
I also find out some link but i can't understand that one.I give the link below
http://www.codeproject.com/KB/aspnet/googlewebclient.aspx

Regards
Murugan K





Responses

Author: VijayaShankar    19 Aug 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 6

link: http://www.communitymx.com/content/article.cfm?page=1&cid=E8E8CE970C6AB073

<%@ Page language="c#" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>Google API Search</title>
</head>
<body>
<form id="GoogleForm" method="post" runat="server">
<asp:TextBox id="tbSearch" runat="server" />
<asp:RequiredFieldValidator id="rfvSearch" runat="server"
ErrorMessage="*" ControlToValidate="tbSearch"/>
<br>
<asp:Button id="btnSearch" onClick="btnSearch_Click"
Text="Search" runat="server"/>
<br><br>
<asp:Literal id="litResults" runat="server"/>
</form>
</body>
</html>


<script runat="server">
public void btnSearch_Click(object sender, System.EventArgs e)
{
if (Page.IsValid)
{
GoogleSearchService searchservice = new GoogleSearchService();
GoogleSearchResult searchresults;
string licensekey = "YOURKEYHERE";
string searchphrase = tbSearch.Text;
StringBuilder sb = new StringBuilder();

searchresults = searchservice.doGoogleSearch(licensekey,
searchphrase, 1, 10, false, string.Empty, true, string.Empty,
string.Empty, string.Empty );

foreach (ResultElement r in searchresults.resultElements)
{
sb.Append("<a href=\"" + r.URL + "\">" + r.title +
"</a><br />");
if (r.snippet != string.Empty)
{
sb.Append(r.snippet + "<br />");
}
if (r.summary != string.Empty)
{
sb.Append("<strong>Description:</strong> " + r.summary +
"<br />");
}
sb.Append("<br />");
}
litResults.Text = sb.ToString();
}
}

</script>



Author: Vidhya    19 Aug 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 6

refer:
To have google search engine on your websitem, follow this link: http://www.google.com/coop/cse/

or
use this code:

<!-- Google CSE Search Box Begins -->
<form action="http://localhost:50536/test.vb/Default4.aspx" id="searchbox_007964276471758046320:xdzvl0vlljs">
<input type="hidden" name="cx" value="007964276471758046320:xdzvl0vlljs" />
<input type="hidden" name="cof" value="FORID:11" />
<input type="text" name="q" size="25" />
<input type="submit" name="sa" value="Search" />
</form>
<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=searchbox_007964276471758046320%3Axdzvl0vlljs&lang=en"></script>
<!-- Google CSE Search Box Ends -->

<!-- Google Search Result Snippet Begins -->
<div id="results_007964276471758046320:xdzvl0vlljs"></div>
<script type="text/javascript">
var googleSearchIframeName = "results_007964276471758046320:xdzvl0vlljs";
var googleSearchFormName = "searchbox_007964276471758046320:xdzvl0vlljs";
var googleSearchFrameWidth = 600;
var googleSearchFrameborder = 0;
var googleSearchDomain = "www.google.com";
var googleSearchPath = "/cse";
</script>
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>
<!-- Google Search Result Snippet Ends -->

or

refer some sample code in this link:
http://www.codeproject.com/KB/applications/SearchDotnet.aspx



Author: jaynesh    29 Dec 2008Member Level: BronzeRating: 2 out of 52 out of 5     Points: 5

1. Create the folder like "Net" within "wwwroot" folder and make that folder web application.
2. Create "bin" sub-folder within the "Net" folder.
3. Make GoogleProxy.cs using the WSDL tool and compile GoogleProxy.cs into the .net assembly using csc command to generate the proxy.
1. >wsdl /l:cs /o:GoogleProxy.cs "http://localhost/Net/GoogleSearch.wsdl">http://localhost/Net/GoogleSearch.wsdl
/n:GoogleWebService
This generates the GoogleProxy.cs. "GoogleSearch.wsdl" is found in the API you have downloaded.
2. >csc /out:GoogleProxy.dll /t:library /r:system.dll, system.web.dll,
system.xml.dll, system.web.services.dll GoogleProxy.cs
This generates the .net assembly, GoogleProxy.dll. Copy the dll file into "bin" folder. Your ASP.NET page will ultimately call the web-callable methods and properties exposed by this dll.
4. Write GoogleClient.aspx file to create the UI and to consume the services exposed by google web api, to be precise GoogleProxy.dll in our case.
5. Browse http://localhost/Net/GoogleClient.aspx. That's it!



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : HOW CAN I FIT ASPX PAGE IN THE CONTENT PLACE HOLDER OF MASTER PAGE....URGENT
Previous : Urgent
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use