我做了一个WEB用户控件,上面放了1个文本框,然后放在一个页面里,我页面上放了一个按钮,单击按钮如何或的WEB用户控件上文本框里的值??
解决方案 »
- 有无办法在自动属性上使用“NonSerialized”特性?
- C# 关於DateTime的问题
- C#如何在已有的一个Excel文件中增加新的Sheet?
- wp8模拟器,一直停留在“windows phone 操作系统正在启动中”。。怎么办?
- 如何获得本地文本的内容
- __——————_小问题小问题
- 关于在WinForm里面登录Web的若干问题
- 求救:广度优先如何遍历??
- httpwebrequest模拟请求奇怪错误
- 有一个DATAGRID的问题,那位大哥能解快一下.谢了.
- sql存储过程返回多结果集的后续处理,帮顶有分!!!
- vs2005使用clickonce时ocx注册问题,十万火急!!!!!!!!!!!!!!
public string test
{
get { return TextBox1.Text;
}
}页面就可以访问了
public string MyString
{
get { return TextBox1.Text;}
}
在web页面中
public class WebForm1 : System.Web.UI.Page
{
protected WebUserControl MyControl;
private void Button1_Click(object sender, System.EventArgs e)
{
string myvalue=MyControl.MyString;//这里是取值
}
}
protected System.Web.UI.WebControls.TextBox TextBox1;private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
public string test
{
get
{
return this.TextBox1.Text;
}
}2.把用户控件拖到页面上,然后定义,代码如下
protected System.Web.UI.WebControls.Button Button1;
protected Document.WebUserControl WebUserControl1;
private void Page_Load(object sender, System.EventArgs e)
{
}
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write(WebUserControl1.test);
}
我前面定义 private WebUserControl MyControl;(这样就不行)
如用户控件名是usercontrol,文本框id是textbox1
那就是usercontrol_textbox1