Dave Burke : Freelance .NET Web Developer specializing in Online Communities

dotText search my blog/all blogs control

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());

 

Comments (2) | Post RSS RSS comment feed

Posted on 2/2/2005 9:31:00 PM by Dave Burke
Categories:
Tags:

Related posts

Comments (2) -

2/2/2005 9:37:00 PM Permalink

hi Dave,
I stumbled upon ur site while trying to get instructions for Cdottext. However, I realised I hit a gold-mine. I am still in infancy as far dot net and DNN and the sorts, but I am gonna take you, scott,   christoc etc    as my mentors and I am gonna make my site into a kick-ass portal.
Great work on the skins, and integration of blogs and Ngallery........
keep up the good work
Rajesh

rajesh valluri |

2/2/2005 9:42:00 PM Permalink

Hey, Man!  You made my day!  I'll do my best to continue motivating you to add more and more kick-ass features.  Regards!

Dave Burke |


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke