function clickRunCode() {
if (document.getElementById("<%=txt_Keywords.ClientID %>").value == '请输入关键字') {
document.getElementById("<%=txt_Keywords.ClientID %>").value = '';
document.getElementById("<%=txt_Keywords.ClientID %>").style["color"] = "black";
}
}
function blurRunCode() {
if (document.getElementById("<%=txt_Keywords.ClientID %>").value == '') {
clickZoom();
}
}
function clickZoom() {
document.getElementById("<%=txt_Keywords.ClientID %>").value = '请输入关键字';
document.getElementById("<%=txt_Keywords.ClientID %>").style["color"] = "gray";
}
<div class="menucolor" style="width: 457px; height: 30px; padding-left: 5px; padding-top: 4px;">
<div style="float: left">
<img src="Resources/images/button_zoom.png" style="width: 26px; height: 26px; cursor: pointer;"
alt="" onclick="clickZoom()" /></div>
<div style="float: left">
<input type="text" id="txt_Keywords" runat="server" style="width: 330px; height: 20px;
vertical-align: middle;" onblur="blurRunCode()" onclick="clickRunCode()" /></div>
<div style="float: left">
<img src="Resources/images/button_search.png" style="width: 90px; height: 27px; cursor: pointer;"
alt="" onclick="clickSearch();" /></div>
</div>
为什么想到用javascript去实现呢?其实以前我都用AjaxControlToolkit.dll这个三方控件去实现,可是现在公司开发规定只以用.net 2.0开发,而AjaxControlToolkit.dll这个控件只能在.net 3.5下运行,于是想出这个方法.