Using Google Custom Search Engine (CSE) with Asp .Net

I’ve been using Google Custom Search Engine (CSE) for one of my projects (searchTravelBlog). When I was trying to implement CSE in NewGuid.NET I found some problems doing this.The big issue is that CSE depends on the html FORM element with submit event for posting all the variables from the hiddenfields. 

The CSE code from Google looks like this:   

[code:html]
<form action="http://" id="searchbox_004900934070880588383:m5qbf6oxe6k">
      <input type="hidden" name="cx" value="004900934070880588383:m5qbf6oxe6k" />
      <input type="hidden" name="cof" value="FORID:11" />
      <input type="text" name="q" size="25" />
      <input type="submit" name="sa" value="Search" />
</form>
[/code]

 

When you copy this code into a .Net page it will not work. This because of the default .Net server form tag.

If you want to use CSE within your .Net page don't use Google's code that generates the search form.  Create your own code, just add one Textbox and one Button control to your page.

[code:html]
<asp:TextBox ID="searchQuery" runat="server" size="30" />
<asp:Button runat="server" Text="Search .Net Info" ID="searchButton" OnClick="searchButton_Click" />
[/code]

 

In the code behind you add the following searchButton_Click event:

[code:c#]
protected void searchButton_Click(object sender, EventArgs e)
{
   StringBuilder redirectUrl = new StringBuilder();
   //The URL to your resultpage
   redirectUrl.Append("./search_netInfo.aspx");
   //Add your CSE unique identifier
   redirectUrl.Append("?cx=004900934070880588383%3Am5qbf6oxe6k");
   //Add your advertising location code
   redirectUrl.Append("&cof=FORID%3A11");
   //The search query
   redirectUrl.Append("&q=" + searchQuery.Text);
   //Redirect to the resultpage
   Response.Redirect(redirectUrl.ToString());
}
[/code]

 

You can find these values in the hidden values from the default code that Google creates for you.It is important that the values within the redirectUrl are html encoded.

Add the following code to your Page_PreRender so that the searchquery will appear in the textbox.

[code:c#]
protected void Page_PreRender(object sender, EventArgs e)
{
   searchQuery.Text = Request.QueryString["q"];
}
[/code]

 

Note: This example doesn't include the branding that Google requires. Please read the branding guidelines here!

obout Suite for .Net 2.0

When surfing around I found this great range ASP.Net controls.  Obout.com offers a great variety of ASP and ASP .Net controls. The controls are Cross-Browser (including Safari  and Opera).You can download the obout Suite for .Net 2.0. The suite contains the following controls:

  • TreeView  (recommended)
  • Grid
  • Editor
  • Spell checker
  • Calendar
  • Easy menu
  • Combobox
  • Slide menu
  • AJAXPage
  • Two colors menu
  • Splitter
  • Super button
  • Tree_DB
  • Autosuggest
  • Show
  • Flyout Window
  • FileUploadProgress
  • Slide Panel (with Slide menu)
  • TabStrip (with Easy Menu) 
  • Context menu (with EasyMenu)
  • Toolbar (with Supper button)
  • State Selector (with Combobox)

There are loads of examples on their website. So go check it out!

Portofolio: Administrative application for 220 pharmacies

Project description:
For a customer of Evident Interactive me and my team build an administrative application. Now 220 pharmacies do their finance administration with this application. The application supports: input from pharmacies, work-flow, reports and data exchange to Twinfield.

My role in the project was Lead-developer the project team had a size of 4 developers.

Used technology:

  • Asp.Net 2.0
  • Asp.Net Ajax
  • Ajax ControlToolkit
  • MSSQL 2005
  • MSSQL Reporting Services
  • Webservices
  • XML
  • HTML, Javascript, CSS

Visual Studio 2008 released

Since a few days the newest version of Visual Studio has been released together with the new 3.5 .Net framework.

It contains tons of new features such as:

  • Javascript Intellisense
  • Multi-targeting support (.Net versions: 2.0, 2.0 and 3.5)
  • Built in AJAX support (no need to install an extra package)
  • New Html web designer (same as Expression Web) and improved CSS support
  • Language improvements and LINQ
  • Access to the .Net Framework Library source code (for more information read this post from Scott Guthrie

When you are a MSDN subscriber you can download it here. If not you can download the 90 day trial of the Team Suite edition here.

Be sure to read this post from Scott Guthrie’s blog 

Silverlight Alpha 1.1 VS 2008 add in

I
just tried to install the VS2008 SilverlightTools Alpha, but I
immediatly ran in to an error. The installation couldn’t start beacause
VS2008 was not installed. This suprised me because I just installed
thirty minutes before. A some searching I found out that I needed to
install the Visual Web Developer.

You can install this by running the VS2008 setup again an choose to add features. Now the Silverlight tools setup runs flawless.

Visual Studio 2008 beta 2 released!

I just installed VS 2008. The first time
that I tried to install it, the installation failed. Apparantly the
image (3 gb!) was corrupted and therefore the installation had troubles
with the cabinet files of the Document Explorer. I downloaded it again
and now the installation went flawless.

Tonight I made my first application. I created an rss reader (bases
on Scott Guthrie’s code) which uses LINQ. I think that LINQ is one of
the most important new features of the .Net 3.5 framework. It is an
feature which uses SQL like statements. I saw an demo of it from Erik
Meijer on the dutch DevDays and I immediatly loved it.

Now the next step is to try and expand the rss reader with Silverlight….