.............................................................MyWeb:.................................................................................
1)document.getElementById("order").value//通过ID访问控件
2)var a = "<%=WebControlID.Text%>"//获取Web控件
var a = "<%=x%>"//获取后台变量
document.getElementById("Label1").innerHTML = <%=this.Request.QueryString["title1"]%>;//获取传递参数
3)<script language="javascript" defer>//defer表示推迟到所有表单被编译以后再执行
4)type="submit" 与type"="button"的区别是submit 执行后会刷新页面
5)document.getElementById("kssc").style.display = "none";//"block"/"inline"其中block还是占空间的
6)文件:<input type="file">//弹出文件选择窗体
7)window.location.href="./com/index.htm";//页面跳转
8)系统获取img 的src时是 = "http://localhost/MyWeb/images/MyWeb/f1.gif";//注意前面的http...
9)insert into adv(title,type,files,pubdate)values('Titfle',3,'fihle','2006/05/05 00:00:05')日期后加时间时需要加上单引号,没时间时可以去掉
10)ToLongDateString();与ToShortDateString();的区别前者是中文 后者是windows默认
...........................................................Other:..............................................................................
1)select convert(varchar(10), pubdate, 121) FROM adv;//从sqlsever中获取日期部分的属性
2)int.Parse(dt.Rows[0][2].ToString());//转化为数字格式
3)location.search.substr(1)//js获取传递来的参数
4)file field的值不只能通过键盘才能写入 代码不能写入 艾...
5)出现过不是是自动编号却没有设好导致插入时不插入如到id列而出错,注意下得
6)<a id="HyperLink1" href="../shezhi/qtlb.aspx" target="rbottom">//target指定在frame里中得哪个位置显示
7)parent.frames['buttomFrame'].frames['buttomBody'].location.href='new.htm'//改变框架的资源
8)MM_goToURL('parent.frames[/'main/']','ad_add.aspx')//DreamWeaver URL跳转时前面个参数用这样用可以控制在哪个框架中显示
9)onClick="window.history.back(-1)"//后退和前进几步功能,只能用在<A></A>间
parent.middle.location.reload();//刷新
10)Random a = new Random();
int value = a.Next(0,100);//产生1-100随机数
filename=System.Guid.NewGuid().ToString();//产生随即字符串
11)this.Request.Files[0].SaveAs(MapPath(filename));//保存文件到硬盘,这里0也可以用name代替
Set delefilepath=deleteFileObject.GetFile(delefilepath)
delefilepath.Delete//删除指定文件
后台使用this.Request.Files[0]获取<INPUT type="file" name="file" runat=server>时,注意要加上
runat=server
12)System.IO.Path.GetExtension(filename);//获取文件后缀名
................................................................Police:........................................................................
1)<base target=_blank> 放到head内可以控制页面的所有链接target属性
_blank ---------- 新开窗口
_self ----------- 自身
_top ------------ 主框架
_parent --------- 父框架
2)<%@ Register TagPrefix="uc10" TagName="lxs" Src="./UserControl/tztb.ascx" %>//加在页面HTML代码的最最前面就可以为用户控件指定其资源位置
<uc10:lxs id="Formtop1" runat="server"></uc10:lxs>//注意nc10的相互对应,lxs的相互对应
3)select top 3 * from 景色图片 order by ID newid()//其中newid()表示随机排序
4)Cache.Insert("dtfclist", dt, null,DateTime.Now.AddMinutes(30), TimeSpan.Zero);//将DT存入内存
5)<%# DataBinder.Eval(Container.DataItem,"保存路径") %>//<% ..%>表示绑定
数据集 ,绑定列名
6)图片的保存方式
1)保存相对路径,读取时如下
src="/<%# DataBinder.Eval(Container.DataItem,"保存路径") %>"
2)保存绝对路进,读取时如下
ImageUrl="F:/Picture/极品飞车.jpg"
7) //前台
<ItemTemplate>
<TABLE height="25" cellSpacing="1" cellPadding="0" width="100%" border="0">
<TR>
<TD style="HEIGHT: 34px"><B><FONT color=green>√</FONT></B><A href='news/shownews.aspx?id=<%# DataBinder.Eval(Container.DataItem,"ID") %>' target=_blank>
<%# Cut(Convert.ToString(DataBinder.Eval(Container.DataItem,"标题")),20) %>
</A>
<%# DataBinder.Eval(Container.DataItem,"图") %>
<asp:Image id=Img2 runat="server" ImageUrl="../images/news/new.gif" Visible='<%# Convert.ToBoolean(DataBinder.Eval(Container.DataItem,"diff")) %>'>
</asp:Image></TD>
<TD style="HEIGHT: 34px" noWrap width="10%"><%# DataBinder.Eval(Container.DataItem,"时间","{0:yyyy-MM-dd}") %></TD>
</TR>
<TR>
<TD background="images/main/bg_01_line.gif" height="1"></TD>
<TD background="images/main/bg_01_line.gif" height="1"></TD>
</TR>
</TABLE>
</ItemTemplate>
//后台
private void bind()
{
System.Data.DataTable dt=null;
string strCommandText=" SELECT TOP 5 ID,ISNULL( ( SELECT '[<font color=#ff0000>图</font>]' WHERE 标题图片<>''),'') AS 图,"+
"ISNULL ( (SELECT 'false' WHERE DATEDIFF(day,时间,getdate())>5),'true') AS diff,ID,标题,时间 from 新闻 Where 类型='法制园地' ORDER BY 时间 DESC";
if(this.cbase.GetData(strCommandText,ref dt)=="s")
{
this.dlList.DataSource=dt.DefaultView;
this.dlList.DataBind();
dt.Dispose();
}
}
//DataList的绑定
...................................................................dx:............................................................................
dt1.Rows[2][0]!=DBNull.Value;表示某行不为空
TextBox1.Text = DateTime.Now.ToString("MM月-dd日-yyyy年",DateTimeFormatInfo.InvariantInfo);
DataGrid1.Items.Count.ToString();
DataFieldFormatStr={0:yyyy-MM-dd};绑定格式控制
this.Page.ToString() = "ASP.try01_aspx":
System.Threading.Thread.Sleep(2000);系统休眠
Request.QueryString["Name"].获取传递参数
..................................................................Dnyy:............................................................................
1)<style></style>放<head></head>之间只能在htm页面中会提示不支持,但是还是强行起作用
2)<marquee></marquee>滚动文字标识符
3)string uName=Request.Form.Get("TextBox1");
或者这样写也可以string uName=Request["TextBox1"];//获取前台html控件值 不需要加上runat="server"
4)System.DateTime.Today.ToString("d")//只获取日期部分
5)表ID记得要加上标识不重复 数字格式
6)sql语句中time类型的需要'"+System.DateTime.Today.ToString("d")+"'加上''
7)Response.Write("<script defer>alert('文章标题和文章内容不能为空。')</script>");//弹出文章标题和文章内容不能为空
8)a href='javascript:οnclick=MM_openBrWindow("<%# DataBinder.Eval(Container.DataItem,"name") %>",<%# DataBinder.Eval(Container.DataItem,"content") %>,<%# DataBinder.Eval(Container.DataItem,"solution") %>)'>
<%# DataBinder.Eval(Container.DataItem,"title") %></a>//弹出窗体动态绑定数据作为参数,暴强 如果不是数字的话,一定要加""
<A href='javascript:οnclick=checkd(<%# DataBinder.Eval(Container.DataItem,"ID") %>)'>删除</A>//看清楚语法了,onclick里面不需要"" javascript在前面
9)先把值进行escape()处理,然后在获取的时候再用unescape()还原!//中文转化
10) document.getElementById("Label3").innerHTML = <%=this.Request.QueryString["solution1"]%>; 只能是数字!
11)setTimeout("window.close()",2000);//设定时间来关闭窗口,只能用在pageload中
12)Response.Write("<script language='javascript'>window.opener=null;window.close();</script>");//在后台执行javascript,这里是关闭当前窗口
13) window.opener.location.reload(); //刷新父窗体页面
如果你的B.asp和a.asp不是一个页面,它是不可能刷新到的。除非在一个页面内的不同框架里
js的文档对象你应该熟悉一下.在页面里window.open()创建的新页面默认的是当前对象的子窗口,继承了父页面的对象模型.
14)test1.htm
====================
<script>
var mxh1 = new Array("mxh","net_lover","孟子E章")
var mxh2 = window.open("about:blank","window_mxh")
// 向对话框传递数组
window.showModalDialog("test2.htm",mxh1)
// 向对话框传递window对象
window.showModalDialog("test3.htm",mxh2)
</script>
test2.htm
====================
<script>
var a = window.dialogArguments
alert("您传递的参数为:" + a)
</script>
test3.htm
====================
<script>
var a = window.dialogArguments
alert("您传递的参数为window对象,名称:" + a.name)
</script>
// window.showModalDialog的使用与参数返回
window.showModalDialog(url,window,'"dialogWidth:400px; dialogHeight:340px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scrollbars:no;Resizable=no; " );//
//弹出所有参数举例
15)<asp:datalist id="dlList" Width="732px" runat="server" BorderWidth="0" CellPadding="0" CellSpacing="0">
//令此控件所有间距为零
16)<style>
.tb{table-layout:fixed}
</style>
//自动换行
16)if(this.cbase.GetData(sqls,ref dt)=="s")//使得DataTable获取数据并判断是否执行成功
17)document.all['Layer2'].style.visibility='hidden';(visible)//获取页面元素并修改样式,这里是隐藏一个层
18)用ajax时一定要记住是public才可以调用,public***************
19)HTML控件的点击是不会刷新页面的,只有加上form表单后才会刷新,用途是表单提交时能保留页面用户所输内容
20)document.location="";//当前框架跳转