My next thought was, if nothing else, encapsulate all the odd options and such into a nice little control. This isn’t necessary for the Yahoo! search, as it’s SDK has it’s own controls, result objects, etc. For the full list of Google AJAX Search options, check out the class reference.
The only method to override in our custom control is CreateChildControls; we’ll use it to populate the page with our JavaScripts.
protected override void CreateChildControls()
{
base.Page.ClientScript.RegisterClientScriptInclude(“apiScript”,
“http://www.google.com/jsapi?key=” + this.Key);
StringBuilder searchers = new StringBuilder();
searchers.AppendLine(“google.load(’search’, ‘1′);”);
searchers.AppendLine(“function initialize() {”);
searchers.AppendLine(“ var searchControl = new
google.search.SearchControl();”);
if (EnableWebSearch)
searchers.AppendLine(“ searchControl.addSearcher(new
google.search.WebSearch());”);
if (EnableImageSearch)
searchers.AppendLine(“ searchControl.addSearcher(new
google.search.ImageSearch());”);
if (EnableVideoSearch)
searchers.AppendLine(“ searchControl.addSearcher(new
google.search.VideoSearch());”);
if (EnableBlogSearch)
searchers.AppendLine(“ searchControl.addSearcher(new
google.search.BlogSearch());”);
searchers.AppendLine(“ searchControl.draw(document.getElementById(’” +
this.ClientID + “‘));”);
searchers.AppendLine(“}”);
searchers.AppendLine(“google.setOnLoadCallback(initialize);”);
base.Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
“searchers”,
searchers.ToString(), true);
}
The apiScript provides the link to the Google JavaScript objects (and passed along the unique key). The searchers is the guts of the search component and generates a JavaScript block wherever you place your control.
Notice on the .draw method of the searchControl, it’s drawing back to itself (the control, by default, generates a span tag; we’re simply returning the “drawing” of the control back to that. It’s possible to add another property, something like TargetControlId, and use that to separate out the search logic and the actual location the search UI is presented.
To place the control on your page, drop and drag it from the toolbar, or code. Here’s an example with the VideoSearch disabled.
<googleControls:GoogleSearch
ID=”GoogleSearch1″
runat=”server”
EnableVideoSearch=”false”
Key=”KEYHERE” />
Unfortunately, this still doesn’t resolve using the Search API for non-web interfaces.
source: tiredblogger.wordpress
Related Stuff
-
MooV: Using cutting edge Video phones and Software Video Phones - coupling all that with VoIP and empowering the disabled.
-
Moo Telecom: VoIP communications made easy - Ring anyway with the fun and ease of using a normal phone
-
TagR:Mobile Social Network with Real Time Locations Based services, and Ambience Intelligence, VoiP, IM, Skype, Googletalk, Mapping, Flickr, Events, Calendaring, Scheduling, SecondLife Support
-
ClearSMS : ClearSMS is a Web-based application that lets you send bulk SMS messages to your customers, contacts, or just about anyone.
-
Jajah:jah is a VoIP (Voice over IP) provider, founded by Austrians Roman Scharf and Daniel Mattes in 2005[1]. The Jajah headquarters are located in Mountain View, CA, USA, and Luxembourg. Jajah maintains a development centre in Israel.
-
Skype: It’s free to download and free to call other people on Skype. Skype the number one voice over ip software
- PrivatePhone: a free local phone number with voicemail and messages you can check online or from any phone.
Be the first ... |Add your comment.
Your Comment ...
Name (required)
Email (required, hidden)
Website
