#region Using
using System;
using System.Web;
using System.Web.UI;
using System.Text;
using BlogEngine.Core;
#endregion
namespace Controls
{
///
/// Includes a reference to a JavaScript.
///
/// This control is needed in order to let the src
/// attribute of the script tage be relative to the root.
///
///
public class SearchBox : Control
{
static SearchBox()
{
BlogSettings.Changed += delegate { _Html = null; };
//Post.Saved += delegate { _Html = null; };
}
private static object _SyncRoot = new object();
private static string _Html;
///
/// Gets the HTML to render.
///
private string Html
{
get
{
lock (_SyncRoot)
{
BuildHtml();
}
return _Html;
}
}
private void BuildHtml()
{
string text = Context.Request.QueryString["q"] != null ? HttpUtility.HtmlEncode(Context.Request.QueryString["q"]) : BlogSettings.Instance.SearchDefaultText;
StringBuilder sb = new StringBuilder();
sb.AppendLine("
");
_Html = sb.ToString();
}
///
/// Renders the control as a script tag.
///
public override void RenderControl(HtmlTextWriter writer)
{
writer.Write(Html);
}
}
}