输入完textbox1的内容。把下一个焦点聚在button1上(输入完内容按回车就执行button1)
(1)TextBox1.Attributes.Add("onkeydown", "if(event.keyCode==13) {document.all." + Button1.ClientID + ".focus();document.all." + Button1.ClientID + ".click();}");
(2)if (event.keycode==13)
document.all('buttonid').focus;
document.all('buttonid').click();
24小时制: DateTime dt = DateTime.Now;
string dt24 = dt.ToString("yyyy-MM-dd HH:mm:ss");
12小时制: DateTime dt = DateTime.Now;
string dt12 = dt.ToString("yyyy-MM-dd hh:mm:ss");
H的大小写决定
客户端图片上传
private void File()
{
try
{
string fullFileName = this.File1.PostedFile.FileName;
string fileName = fullFileName.Substring(fullFileName.LastIndexOf("//") + 1);
string type = fullFileName.Substring(fullFileName.LastIndexOf(".") + 1);
if (type.ToLower() == "jpg" || type.ToLower() == "bmp" || type.ToLower() == "gif")
{
string NewImgName = DateTime.Now.Year.ToString() + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + DateTime.Now.Millisecond;
string files = NewImgName +"."+ type;
this.File1.PostedFile.SaveAs(Server.MapPath("img") + "//" + files);
n_url = "img/" + files;
}
else
{
n_url = "1";
}
}
catch (Exception ex)
{
throw ex;
}
}
跳转到指定的位置(提转到id位reply的位置)
οnclick="location.hash='reply'"
οnclick="location.href='reply'"
获取datalist 控件容器里面指定的内容
protected void Button1_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
DataListItem item = (DataListItem)btn.NamingContainer;
string str = ((Label)item.FindControl("Label17")).Text;
int i=tgInfoClass.delinfo(str);
if (i == 1)
{
Response.Redirect("dingfang.aspx");
}
else
{
Response.Write("<script> alert('删除不成功!')</script>");
}
}
<a href="#redfox" οnclick="window.open('shoucang.aspx?id=<%=id %>','收藏','height=450, width=510, top=50,left=50, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no')">收藏此问题</a>
textbox 只能输入数字
在TextBox的KeyPress事件里判断输入值的ASC码,如果不为数字就把e.Handled设为Ture,取消KeyPress事件
Page.RegisterStartupScript("提示", "<script>alert('验证码输入错误!');</script>");
禁止FileUpload输入 asp.net禁止FileUpload输入 asp.net <asp:FileUpload ID="FUApplyFileContent" runat="server" Width="240px" BorderColor="Gray" οnkeydοwn="event.returnValue=false;" οnpaste="return false" />禁止FileUpload输入
asp.net
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('发布信息,请先到商务168主站登陆!');window.location.href='http://www.shangwu168.com/index.aspx'</script>");
Response.Write("<script language='javascript' type='text/javascript'>window.alert('注册成功,2秒钟跳转到登陆页面!')</script>"+ "<meta http-equiv=refresh content=2;URL='loginon.aspx'>");