您的位置:首页 > Web前端 > JavaScript

从C#后台输出JS代码

2013-01-31 08:36 295 查看
// 这里是主表输出是 自定义表格格式函数
private bool bSwitch = false;
string color1 = "#ffffcc";
string color2 = "#ccff99";

/// <summary>
/// 定义搜索后列表 主表样式输出
/// </summary>
/// <param name="con"></param>
/// <returns></returns>
public string TRJavaScript(Control con)
{
string tmp;
DataListItem dli = con as DataListItem;
Button btn = dli.FindControl("HiddenButton") as Button;
string _js = "bgcolor={0} onMouseover='rowcolor=this" +
".style.backgroundColor;this.style.backgroundColor" +
"=\"#00FF28\"; this.style.cursor = \"hand\"' " +
"onMouseout='this.style.backgroundColor=rowcolor;' " +
" onclick='document.getElementById(\"{1}\").click();' ";
tmp = bSwitch ? string.Format(_js, color1, btn.ClientID) :
string.Format(_js, color2, btn.ClientID);
bSwitch = !bSwitch;
return tmp;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: