ASP.NET中页面传值 (传统方法)
一、目前在ASP.NET中页面传值共有这么几种方式:
1、表单提交,
<form action= "target.aspx" method = "post" name = "form1">
<input name = "param1" value = "1111"/>
<input name = "param2" value = "2222"/>
</form>
....
form1.submit();
....
此种方在ASP。NET中无效,因为ASP。NET的表单总是提交到自身页面,如果要提交到别一页面,需要特殊处理。
2、<A href="target.aspx?param1=1111¶m2=2222">链接地址传送</A>
接收页面: string str = Request["param1"]
3、Session共享
发送页面:Session("param1") = "1111";
按收页面 string str = Session("param1").ToString();
4、Application共享
发送页面: Application("param1") = "1111";
按收页面: string str = Application("param1").ToString();
此种方法不常使用,因为Application在一个应用程序域范围共享,所有用户可以改变及设置其值,故只应用计数器等需要全局变量的地方。
5、Cookie
6、Response.Redirect()方式
Response.Redirect("target.aspx?param1=1111¶m2=2222")
接收页面: string str = Request["param1"]
7、Server.Transfer()方式。
Server.Transfer("target.aspx?param1=1111¶m2=2222")
接收页面: string str = Request["param1"]
二、如果在两个页面间需要大量的参数要传传递,如数据查询等页面时,用1 - 6的方法传值及其不便,而第 7 种方法确有一独特的优势!但使用该方法时需要一定的设置,现简单介绍一下该方法的使用方式:
以查询数据页面为例:
在查询页面中设置如下公有属性(QueryPage.aspx):
public class QueryPage : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox txtStaDate;
protected System.Web.UI.WebControls.TextBox txtEndDate;
...
/// <summary>
/// 开始时间
/// </summary>
public string StaDate
{
get{ return this.txtStaDate.Text;}
set{this.txtStaDate.Text = value;}
}
/// <summary>
/// 结束时间
/// </summary>
publi
相关文档:
本贴来自ZDNetChina中文社区 http://bbs.zdnet.com.cn/
本贴地址:http://bbs.zdnet.com.cn/viewthread.php?tid=108315
如果你已经有较多的面向对象开发经验,跳过以下这两步:
第一步 掌握一门.NET面向对象语言,C#或VB.NET 我强烈反对在没系统学过一门面向对象(OO)语言的前提下去学ASP.NET。 ASP.NET是 ......
1.对IE浏览器进行设置
文件-〉页面设置-〉将里面的页眉和页脚的内容清空 就OK了
2.页面代码实现 Javascript
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><!-- & ......
ASP.NET(C#)返回上一页(后退)代码
2008-08-10 10:32
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["BackUrl"] = Request.UrlReferrer.ToString();
}
}
/// <s ......
总结asp.net开发常用的方法一
using System;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.IO;
namespace MoneyWise
{
/// <summary>
/// utils 的摘要说明。
/// </summary>
public class utils
{
pr ......
asp.net 开发中常用的一些方法总结虽然写的不好,但很实用
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Net;
using System.Text.RegularExpressions;
using System.Web.UI;
using System.Web.SessionState;
using System.Web.UI.WebControls;
using Syst ......