我写了一个ascx控件myusercontrol,其中放置了两个控件:
1、标签控件mylabel
2、按钮控件mybutton
在点击mybutton按钮时,将打开一个新的页面bb.aspx。在bb.aspx页面中,包含两个控件:
1、textbox控件mytextbox
2、按钮控件mybutton2
在点击mybutton2时,需要将mytextbox的值传回myusercontrol控件中的mylabel中。目前除了使用Cache实现外,还没有其它的办法,谢谢大家的意见!
1、标签控件mylabel
2、按钮控件mybutton
在点击mybutton按钮时,将打开一个新的页面bb.aspx。在bb.aspx页面中,包含两个控件:
1、textbox控件mytextbox
2、按钮控件mybutton2
在点击mybutton2时,需要将mytextbox的值传回myusercontrol控件中的mylabel中。目前除了使用Cache实现外,还没有其它的办法,谢谢大家的意见!
protected string 变量名;public string 属性名
{
get
{
return ....;
}
set
{
....=value;
}
}
protected string text;public string Text
{
get
{
return ....;
}
set
{
....=value;
}
}
然后再加入一对像方法,在aspx的按钮为属性加载值,然后再调用对像方法给ascx中的Label值!
myusercontrolID.属性名=mytextbox.Text;
是这麽个过程吗?
<script language="javascript">
function PopupOption(ctl)
{
var PopupWindow=null;
PopupWindow=window.open('bb.aspx?Ctl=' + ctl,'this is bb.aspx','');
PopupWindow.focus();
}
</script>2、在后台的Page_Load(object sender, System.EventArgs e)中加入以下语句:
this.mybutton.Attributes.Add("onclick",
"javascript:PopupOption('" + this.mylabel.ClientID + "');");3、在bb.aspx页面的前台页面中加入以下脚本:
<script language="javascript">
function saveCheck()
{
ctl = window.location.search.substr(5);
var mytextbox = document.getElementById("mytextbox");
window.opener.document.forms[0].elements[ctl].value = mytextbox.value;
self.close();
}
</script>4、在bb.aspx页面的Page_Load(object sender, System.EventArgs e)中加入语句:
this.mybutton2.Attributes.Add("onclick","saveCheck()");5、新建一个页面test.aspx,拖一个usercontrol1控件上去,不用写任何代码,只要将它设置成起始页就可以了。