dota2错误代码 2:Asp.net 中常用js总结(一)
(一).确认删除用法:
1. BtnDel.Attributes.Add("onclick","return confirm('"+"确认删除?"+"')");
2. linktempDelete.Attributes["onclick"]="javascript:return confirm('"+"确认删除?"+"');";
3. private void grdProject_ItemDataBound(object sender, DataGridItemEventArgs e)
4.
{
if ((e.Item.ItemType == ListItemType.Item) | (e.Item.ItemType == ListItemType.AlternatingItem))
{
// 刪除按鈕上的提示部分
e.Item.Cells[10].Attributes.Add("onclick", "return confirm('确定删除吗?');");
}
}
5.
(二).跨语言字符串替换
System.Text.RegularExpressions.Regex.Replace(str1,@" <{1}[^ <>]*>{1}","").Replace(" ","").Replace("\","http://www.360doc.com/file://%22).replace(%22-%22,%22-%22).replace(%22&%22,%22&%22).replace(%22</;"," <").Replace(">",">").Replace("br","\n");
(三).关闭窗体
1.
this.btnClose.Attributes.Add("onclick", "window.close();return false;");
2.关闭本窗体间跳转到另一个页面
this.HyperLink1.NavigateUrl = "javascript:onclick=window.opener.location.assign
('" + "index.aspx"+ "?&Func=Edit&AutoID=" + intAutoid + ');window.close();";
3.关闭父窗体:
4.关闭本弹出窗体,并刷新父页面
this.Response.Write(" ");
(四).Web MessageBox
1.
Response.Write(" ");
2.
Response.Write(" ");
3.
this.Page.RegisterStartupScript("ChiName"," ");
(五).DataGrid中加CheckBox控件模板列.
1. DataGrid中的代码主要片段:
//头模板代码
onclick="javascript:SelectAll(this);">
//项模板代码
2. 在当页加入:
3.当使用者选择好后台代码取得某列CheckBox的值:
for (int i = 0;i{
bool blnIfSelect = ((CheckBox)this.DataGrid.Items[i].FindControl("chkItem")).Checked;
....;
}