Pages

Wednesday, May 8, 2013

TELERIK: Search filter water mark fix.

C# CODE:

protected void gvProjectsList_OnItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridFilteringItem)
{
GridFilteringItem filerItem = (GridFilteringItem)e.Item;

TextBox textItem = (TextBox)filerItem["ProjectNameFilter"].Controls[0];

if (string.IsNullOrEmpty(textItem.Text))
{
textItem.Text = @"Search project Name...";

textItem.Attributes.Add("onBlur", "return SetMessage(" + textItem.ClientID + ");");

}              
 
textItem.Attributes.Add("onFocus", "return ClearMessage(" + textItem.ClientID + ");");
}

}

 

SCRIPT CODE:

<script language="javascript" type="text/javascript">

//code to hide/show water mark on search box.

function ClearMessage(obj) {

if (obj.value == "Search project Name...")

obj.value = "";
}

function SetMessage(obj) {

if (obj.value == "")

obj.value = "Search project Name...";

}
 
</script>

       

       





 

No comments:

Post a Comment