On my dotText blog I added a "Search My Blog" link to the MyLinks control, with both the search form and results on the same page. But my dotText Freelance Fun One project (that's its codename) the search form is on the sidebar. I was never a fan of the Sidebar Search Widget, but the more I work with it the more I like it.
When approaching the sidebar control, I was wondering how I was going to pass a detailed search string to a page by redirection. It seems ScottW's 0.96 thinking already had this covered, both for a search form on the results page itself or launched from a sidebar control. Yes, Server.UrlEncode is a wonderful thing. (example below.)
Apart from the sidebar search formette on the aggregated home page that searches all blogs, here's the sidebar search control on the individual blog which provides an option.
I put this area in its own skin control named SearchForm.ascx. The trick of searching the individual's blog or all blogs was in passing a boolean value to the BlogSearch.ascx control (the control which displays the results) which set the FilterByBlog property. Here's the btnSearch_OnClick() method.
protected void btnSearch_OnClick(object sender, System.EventArgs e)
{
string searchText = txtSearch.Text;
if(searchText.Trim().Length > 0)
{
LogManager.Log("Search Terms",txtSearch.Text);
string _path = CurrentBlog.FullyQualifiedUrl + "search.aspx";
// s = radiobutton true - myblog only; false - all blogs search
Response.Redirect(string.Format("{0}?s={2}&q={1}", _path,Server.UrlEncode(searchText), rblMyBlog.SelectedItem.Value.ToString()));
Response.End();
}
}
Notice the new cool LogManager.Log() method from 0.96. I added the "string _path..." so the page would always default back to the http://blogsite/blogger root page. To handle My Blog/All Blogs I added a QueryString["s"] based on the Search Form RadioButtonList selection. Then in BlogSearch.ascx I used that value to set the FilterByBlog property.
if(Request.QueryString["s"] != null)
FilterByBlog = bool.Parse(Request.QueryString["s"].ToString());