欢迎来到天天文库
浏览记录
ID:20668133
大小:78.00 KB
页数:14页
时间:2018-10-14
《asp笔记及其常见错误分析》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、2500元电脑配置单组装电脑石材背景墙8.41.UpdatePanel控件由于UpdatePanel控件的引入,postback被分为两种,asynchronouspostback和normalpostback,asynchronouspostback引起UpdatePanel的更新,normalpostback引发整个页面的更新。使用ScriptManager的IsInAsyncPostBack属性可以判断回传的类型。<1>Triggers有两种AsyncPostBackTrigger,PostBackTrigger
2、。AsyncPostBackTrigger来指定某个控件的某个事件引发异步回传(asynchronouspostback),即部分更新。属性有ControlID和EventName。分别用来指定控件ID和控件事件,若没有明确指定EventName的值,则自动采用控件的默认值,比如button就是click。把ContorlID设为UpdatePanel外部控件的ID,可以使外部控件控制UpdatePanel的更新。PostBackTrigger来指定UpdatePanel内的某个控件引发整个页面的更新(normalpo
3、stback)。<2>UpdateMode有两个值:Always,Conditional。总是更新,有条件更新。确定当asynchronouspostbacks发生时,是否总是更新。若页面中只有一个UpdatePanel控件,这个值好像没有什么意义。但是当页面中存在多个Up
4、datePanel,或者UpdatePanel中包含UpdatePanel的复杂情况时,这个值的设定就可以使各个UpdatePanel在各种合适时机更新。<3>ChilderAsTriggersbool值,默认是true。若设为false,则UpdatePanel的子控件引发异步回传(asynchronouspostback),但是不更新当前UpdatePanel(在多个UpdatePanel的页面中发现的)。这里比较难于理解,甚至我理解的是错误的。请高手指点。该属性只在UpdateMode=Conditional条件
5、下有意义。右UpdateMode为Always,ChilderAsTriggers=false就则引发异常。2.数据库的连接(1)数据的增加{using(SqlConnectionconn=newSqlConnection("DataSource=WIN-7UNU1HLJ5GI;InitialCatalog=MyTest;UserID=sa;Password=sun123456")){conn.Open();2500元电脑配置单组装电脑石材背景墙using(SqlCommandcmd=conn.CreateComman
6、d()){//CommandText为要执行的SQl语句cmd.CommandText="insertintoT_Students(Name,Age)values('lixi',17)";cmd.ExecuteNonQuery();//执行}}MessageBox.Show("执行完成!");}(2)数据的查询using(SqlConnectionconn=newSqlConnection("DataSource=WIN-7UNU1HLJ5GI;InitialCatalog=MyTest;UserID=sa;Passw
7、ord=sun123456")){conn.Open();using(SqlCommandcmd=conn.CreateCommand()){//cmd.CommandText="selectcount(*)fromT_StudentswhereAge>10";//inti=(int)cmd.ExecuteScalar();//MessageBox.Show(i+"条数据");}(3)查询自动生成的Idusing(SqlConnectionconn=newSqlConnection("DataSource=WIN-7U
8、NU1HLJ5GI;InitialCatalog=MyTest;UserID=sa;Password=sun123456")){conn.Open();using(SqlCommandcmd=conn.CreateCommand()){cmd.CommandText="insertintoT_Students(Name,Age)o
此文档下载收益归作者所有