Webform 内置对象 Session对象、Application全局对象,ViewState详细介绍
作者:zl大王派我来巡山 时间:2023-06-30 02:14:07
Session
每台电脑访问服务器,都有独立的session,key值都一样,内容不一样。
1.session保存在服务器上。
2.session没有持久性,保存周期就是20分钟。
重点: session不要滥用,不要不用,滥用会造成服务器溢出,不用会造成资源浪费。
赋值:Session["key"] = 值;
取值:string a = Session["key"];
清除: Session["key"]=null;
Application
Application["key"] 是所有的用户获取这个key里面的值都是一样的, 没有保存周期,他会一直保存着, 通常用作版本号
赋值:Application["key"]=值;
取值:Application.Get("key");
Repeater的Command操作:
ItemCommand事件 —— 在Repeater中所有能触发事件的控件,都会来触发这一个事件
CommandName —— 判断点击的是什么按钮,e.CommandName
CommandArgument —— 触发事件所传递过来的主键值数据,放在这里面界面值绑定时要用 单引号 e.
ItemCreated - 项模板中将HTML代码生成完毕时执行一遍此事件
ItemDataBound - 项模板将数据绑定后执行一遍此事件
例子:
<ItemTemplate>
<tr class="tr_Item" style="<%#Eval("Blue") %>" >
<td><%#Eval("UserName") %></td>
<td><%#Eval("Password") %></td>
<td><%#Eval("NickName") %></td>
<td><%#Eval("SexName") %></td>
<td><%#Eval("birthdayn" )%></td>
<td><%#Eval("Age" )%></td>
<td><%#Eval("NationName") %></td>
<td><asp:Button ID="Button1" runat="server" Text="删除" CommandName="delete" CommandArgument='<%#Eval("UserName") %>'/>
<asp:Button ID="Button2" runat="server" Text="修改" CommandName="xiugai" CommandName="delete" CommandArgument='<%#Eval("UserName") %>' />
</td>
</tr>
</ItemTemplate>
后台代码:
if (e.CommandName == "delete")//删除按钮
{
new UserDA().delete(e.CommandArgument.ToString());
Repeater1.DataSource = new UserDA().select();
Repeater1.DataBind();
}
if (e.CommandName == "xiugai")
{
new UserDA().select(e.CommandArgument.ToString());
Repeater1.DataSource = new UserDA().select();
Repeater1.DataBind();
}
通过此文,希望能帮助到大家理解,此部分的知识,谢谢大家对本站的支持!
来源:http://www.cnblogs.com/zl1121102942/p/5906915.html
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
js定时器怎么写?就是在特定时间执行某段程序
python GUI库图形界面开发之PyQt5动态加载QSS样式文件
![](https://img.aspxhome.com/file/2023/5/118585_0s.png)
Golang Mutex互斥锁深入理解
![](https://img.aspxhome.com/file/2023/8/134348_0s.jpg)
python实现批量转换图片为黑白
![](https://img.aspxhome.com/file/2023/4/118534_0s.jpg)
Python从数据库读取大量数据批量写入文件的方法
MySQL教程:Group By用法
python 删除字符串中连续多个空格并保留一个的方法
浅谈Python由__dict__和dir()引发的一些思考
详解用Python进行时间序列预测的7种方法
![](https://img.aspxhome.com/file/2023/9/135109_0s.jpg)
SQLServer 全文检索(full-text)语法
python实现机器学习之多元线性回归
![](https://img.aspxhome.com/file/2023/5/120355_0s.png)
Go语言中int、float、string类型之间相互的转换
学习Python中一些实用的库
![](https://img.aspxhome.com/file/2023/3/117343_0s.png)
MySQL数据库恢复(使用mysqlbinlog命令)
OpenCV哈里斯角检测|Harris Corner理论实践
![](https://img.aspxhome.com/file/2023/6/102346_0s.png)
浅析python 内置字符串处理函数的使用方法
python设计模式之抽象工厂模式详解
![](https://img.aspxhome.com/file/2023/7/76127_0s.jpg)
对tf.reduce_sum tensorflow维度上的操作详解
python 下载文件的多种方法汇总
![](https://img.aspxhome.com/file/2023/7/105017_0s.gif)