复制代码 代码如下:
Response.Expires = 0;
Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1);
Response.AddHeader("pragma", "no-cache");
Response.CacheControl = "no-cache";
复制代码 代码如下:
public override void VerifyRenderingInServerForm(Control control)
{
//(必须有)
//base.VerifyRenderingInServerForm(control);
}
public void Generate(string Typename, string scswId, GridView TempGrid)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Charset = "utf-8";
string Filename = Typename + scswId + ".xls";
HttpContext.Current.Response.AppendHeader("Content-Disposition", "online;filename=" + Filename);
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
HttpContext.Current.Response.ContentType = "application/ms-excel";
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
TempGrid.RenderControl(oHtmlTextWriter);
HttpContext.Current.Response.Write(oStringWriter.ToString());
HttpContext.Current.Response.End();
}
复制代码 代码如下:
ScriptManager.RegisterStartupScript(this.Page, GetType(),
"askAndRederect", "alert('请先登录!');window.location.href='Index.aspx';", true);
复制代码 代码如下:
((LinkButton)e.Row.Cells[4].Controls[2]).Attributes.Add("onclick", "javascript:return confirm('您确认要删除吗?')");
复制代码 代码如下:
protected void GVLinkman_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}
复制代码 代码如下:
//验证手机号
Regex r = new Regex(@"^(13|15|18)/d{9}$");
return r.IsMatch(mobilePhone);
//带86或者+86的手机号
Regex regexMobile = new Regex(@"^((/+86)|(86))?(13|15|18)/d{9}$");
//验证是否为中文
Regex regex = new Regex("^[一-龥]+$");
//Decimal(8,4)类型小数的验证
Regex rx = new Regex(@"^-?(?:[1-9][0-9]{0,3}|0)(?:/.[0-9]{1,4})?$");
//验证输入是否为数字和字母的组合
regex = new Regex("^[一-龥_a-zA-Z0-9]+$");
//验证输入是否全为数字
regex = new Regex("^[0-9]+$");
//验证输入是否全为中文
regex = new Regex("^[一-龥]+$");
//电子邮件
regex=new Regex(@"^([/w-/.]+)@((/[[0-9]{1,3}/.[0-9]{1,3}/.[0-9]{1,3}/.)|(([/w-]+/.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(/]?)$");
//验证网址
regex = new Regex(@"http(s)?://([/w-]+/.)+[/w-]+(/[/w- ./?%&=]*)?");
//电话号码
regex = new Regex(@"(/d{3})?/d{8}|(/d{4})(/d{7})");
复制代码 代码如下:
function document.onkeydown()
{
if(event.keyCode == 13)
{
button.click();//点击回车键调用button的点击事件
event.returnValue = false;//取消回车键的默认操作
}
}
复制代码 代码如下:
function document.onkeydown()
{
//使用document.getElementById获取到按钮对象
var button = document.getElementById('<=serverButton.ClientID%>');
if(event.keyCode == 13)
{
button.click();
event.returnValue = false;
}
}
新闻热点
疑难解答
图片精选