同一页面传值问题 比如在button1的点击事件里会有一个变量a,我如何在button2的点击事件里获得button1的变量a的值? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 使用 ViewState 保存起来。 哥们给个事例代码看看OK吗?比如 a.text = b.text来个简单易懂的 string strGlobal;Button1_Click(){ ViewState["value"] = a;//用ViewState Session["Value"] = a; //用Session Response.Redirect("thisPage.aspx?a="+ a); strGlobal = a;}Button2_Click(){ string strViewState = ViewState["value"].ToString(); string strSession = Session["Value"].ToString(); string strQueryString = Request.QueryString["a"].ToString(); string strGlobal = strGlobal;}这四种都可以。 还可以这样:Button1_Click(){ Button2.CommandName = a;}Button2_Click(){ string str = Button2.CommandName;} private void button1_click(object sender, System.EventArgs e){ ViewState["test"]=xxx;}private void button2_click(object sender, System.EventArgs e){ yyy=ViewState["test"].ToString();} ViewState 有没有存储空间限制?strGlobal 这个是怎么用的? 我用的是VB.NET 我public了一个变量无法使用. 1 - ViewState 有没有存储空间限制?2 - strGlobal 这个是怎么用的? 我用的是VB.NET 我public了一个变量无法使用.答:1 - 内存有多大,ViewState 就有多大。2 - 我是用C#的,VB 可能是 public Dim strGlobal AS String 大家看看,这段代码在asp.net中如何运行 对于实体类的一点疑惑 如何在页面里调用 ocx 请问:为什么直接能够访问的aspx文件和dll文件,在vs里面编译出错? 出现如下错误,望大家帮个忙,看看是什么错误 ASP与ASP.NET的区别及联系 datagrid问题 这个VB.Net的asp.net程序改为C#的就报错!怎么回事? 请问这样的sql语句怎么写。。。在线等。。送分 asp.net.mvc连接数据库时出现问题 asp.net 多文件上传+描述 一个用户验证问题,急~~
比如 a.text = b.text
来个简单易懂的
{
ViewState["value"] = a;//用ViewState
Session["Value"] = a; //用Session
Response.Redirect("thisPage.aspx?a="+ a);
strGlobal = a;
}Button2_Click()
{
string strViewState = ViewState["value"].ToString();
string strSession = Session["Value"].ToString();
string strQueryString = Request.QueryString["a"].ToString();
string strGlobal = strGlobal;
}这四种都可以。
{
Button2.CommandName = a;
}Button2_Click()
{
string str = Button2.CommandName;
}
{
ViewState["test"]=xxx;
}
private void button2_click(object sender, System.EventArgs e)
{
yyy=ViewState["test"].ToString();
}
strGlobal 这个是怎么用的? 我用的是VB.NET 我public了一个变量无法使用.
2 - strGlobal 这个是怎么用的? 我用的是VB.NET 我public了一个变量无法使用.答:
1 - 内存有多大,ViewState 就有多大。
2 - 我是用C#的,VB 可能是 public Dim strGlobal AS String