我如何使用全局变量(会话,查询字符串,-除外)

问题描述:

编码员 在使用母版页时,如何在我们的Web表单上传递全局变量(会话,查询字符串,-除外) 当我使用以下代码 ----------------------- firstform.aspx ------- 受保护的void Button1_Click(对象发送者,EventArgs e) { int c =函数名; Server.Transfer("frmmain.aspx"); } 公共int函数名 { 得到 { 返回Convert.ToInt32(dropdownlist1.SelectedItem.Value); } } ------- frmmain.aspx ------------ <%@参考Page ="firstform.aspx"%> 格式a1; a1 =(firstform)Context.Handler; int a = a1.functionname; ---------------- 在执行此操作时,显示以下错误 无法将类型为"ASP.frmmain_aspx"的对象转换为类型为"firstform"的对象. 谢谢 Pradeep

Hi Coders How can i use global variables (except session,querystring,--)passing over our webforms while using masterpage when i using the followingcode -----------------------firstform.aspx------- protected void Button1_Click(object sender, EventArgs e) { int c = functionname; Server.Transfer("frmmain.aspx"); } public int functionname { get { return Convert.ToInt32(dropdownlist1.SelectedItem.Value); } } -------frmmain.aspx------------ <%@ Reference Page="firstform.aspx" %> firstform a1; a1 = (firstform )Context.Handler; int a=a1.functionname; ---------------- while doing this the following error is showing Unable to cast object of type ''ASP.frmmain_aspx'' to type ''firstform''. Thanks Pradeep

亲爱的朋友,

写Server.Transfer("frmmain.aspx",true)而不是Server.Transfer("frmmain.aspx");

Write Server.Transfer("frmmain.aspx",true) instead of Server.Transfer("frmmain.aspx");

并为frmmain.aspx编写以下代码

And write following code for frmmain.aspx

> --- ---- frmmain.aspx ------------

firstform a1 = (firstform)上一页;

int a = a1.functionname;

>  

> . ..