一:JQuery实现在GridView中 点击一行的任意位置 选中这一行中的CheckBox
$(function(){
$("#GridView1").find("tr").click(function(){
$(this).find("input[type='checkbox']").attr("checked",!$(this).find("input[type='checkbox']").attr("checked"));
});
})
二:在ASP.NET后台实现 GridView 光棒效果
protected void gvProjectList_RowDataBound(object sender, GridViewRowEventArgs e)
{
//这是鼠标移到某行时改变某行的背景
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#eaeaea';");
//鼠标移走时恢复
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor;");
}
前台实现:
<ItemTemplate>
<asp:LinkButton ID="LinkDelete" runat="server" Visible ="false" OnClientClick="if(!confirm('确定要删除这条纪录吗?')) return false;"
CommandName="lb_delete" Text="删除" CommandArgument='<%#Bind("aa") %>' />
</ItemTemplate>
后台实现:
//数据绑定时对删除按钮添加提示
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//只有数据行才有绑定数据
if (e.Row.RowType == DataControlRowType.DataRow)
{
//由于是链接按钮所以声明一个链接按钮,根据实际情况变动
LinkButton lnkBtFalg = e.Row.Cells[0].Controls[0] as LinkButton;
lnkBtFalg.Attributes.Add("onclick", "javascrip:return confirm('您真要的删除吗!')");
}
}
四:在服务器端写js脚本 弹出对话提示框
public static void ShowMessage(System.Web.UI.Page thePage,string Text)
{
Text = Text.Replace("\"", "").Replace("'", "").Replace("\r", "").Replace("\n", "");
thePage.ClientScript.RegisterStartupScript(thePage.GetType(), Guid.NewGuid().ToString(),
"alert('"+Text+"');", true);}
五:Md5加密算法
public static string Md5Hash(string text)
{
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(text);
MD5 md5 = MD5.Create();
byte[] resultBytes=md5.ComputeHash(bytes);//md5
string md5Result = "";
for (int i = 0; i < resultBytes.Length; i++)
{
md5Result += resultBytes[i].ToString("X2");
}
return md5Result;
}
六:后台显示先提示对话框 后跳转页面
1、Response.Write("<script>alert('查询语句执行出错!');window.location.href=DisplayData.aspx</script>");
2、Page.RegisterStartupScript("msg", "<script>alert('查询语句执行出错!');window.location.href='DisplayData.aspx'</script>");
一般后台弹出提示框,都是用Page.RegisterStartupScript,不用Response.Write的
3、ClientScript.RegisterStartupScript(this.GetType(), " ", " <script lanuage=javascript> alert(' ');location.href=' ';</script>");
4、System.Web.HttpContext.Current.Response.Write(String.Format("<script language=\"javascript\">alert(\"{0}\");window.location.replace(\"{1}\")</script>", strMessage, strRedirectUrl));
5、ScriptManager.RegisterStartupScript(this, this.GetType(), "u1", "alert('内容!')", true);
6、Page.ClientScript.RegisterStartupScript(this.GetType(), "d", "alert('请先登录!');location='../login.aspx';", true);