asp.net 页面传值
直接获得页面参数:
if(!IsPostBack) { //判断是否是第一次加载窗体
}
if(Page.PreviousPage!=null){ // 判断上一页面的按钮是否设置了PostBackUrl属性
if(PreviousPage.IsCrossPagePostBack){ //判断页面是否使用跨页提交
TextBox keyword = this.PreviousPage.FindControl(id) as TestBox; // 获得上一页面的相对应ID的值
}
}
使用范围变量:
Cookie对象:(保存在客服端)
语法:
Response.Cookies[Cookie的名称].value = 变量名;
string 变量名 = Request.Cookies[Cookie的名称].value;
HttpCookie hcCookie = new HttpCookie("Cookie的名称","值");
Response.Cookies.Add(hcCookie);
属性:
Name / Value / Expires(设定Cookie变量的有效时间)
Session对象:(保存在服务器)
语法:
Session["Session名称"] = 值;
变量 = Session["Session名称"];
属性:
TimeOut / Clear(从会话状态集合中移除所有的键和值) / Abandon (结束Session,取消当前会话)
Application对象:
语法:
Application["Application名称"] =
相关文档:
在使用asp.net编写webservice时,默认情况下是不支持session的,但我们可以把WebMethod的EnableSession选项设为true来显式的打开它,请看以下例子:
1 新建网站WebSite
2 新建web服务WebService.asmx,它具有以下两个方法:
[WebMethod(EnableSession = true)]
public string Login(string name)
{
  ......
更新方法一,直接在GridView中来更新数据.
更新方法二,打开一个新的页面来更新数据.
//更新
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
&nbs ......
//压缩
protected void btnY_Click(object sender, EventArgs e)
{
string rar;
RegistryKey reg;
string args;
ProcessStartInfo procStart;
Process process;
try
{
reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\Command"); ......
ASP.NET打开新页面而不关闭原来的页面
Respose.Write("<script language='javascript'>window.open('"+ url +"');</script>"); (打开简洁窗口):
Respose.Write("<script l ......
许多程序员在做业务开发时往往会在服务器端做用户信息的验证,有没有考虑过用jquery的ajax方法来验证登陆呢?且效果比在服务器端写代码来验证好的多,页面无刷新即可实现实现登陆验证,代码也简单。
现在下面贴出来的是很简单的用jquery的ajax方法来验证登陆的代码,适合刚接触jquery的朋友学习。
前台页面代码:
<he ......