我试了在用户控件设置一个公共属性,在页面上也赋好了属性的值(页面文本框的值)
---------------------------
你是在什么地方赋值的?页面的Page_Load事件里?还是事件处理函数里?
---------------------------
你是在什么地方赋值的?页面的Page_Load事件里?还是事件处理函数里?
解决方案 »
- .net中将Gridview数据导出到Excel用什么方法比较好?
- ASP.NET时间问题
- 如何实现用户在登录后只是登录框刷新,而页面的其他部分不刷新
- 请教关于框架的内存释放
- 极度痛苦中,我该何去何从?
- checkbox控件用JS控制不可选 当可在服务器获得值
- 类中遇到的一点应用问题==================
- treeview控件为什么有时候展开了页面就死了?听说是微软控件的一个bug?谁能解决这个问题呀?
- 求电子书《Building Web Solutions with ASP.NET and ADO.NET》
- .net与sql连接的问题,请教!
- 寻精通财务和大型ERP的人员,另问下载数据的文件,怎么能够直接打开,不下载!
- datagrid控件中有两个模板列,分别为checkbox和textbox,需要实现当textbox值不为空时,自动将checkbox打钩
含有用户控件的一般页面的处理顺序:1.页面的Page_Load函数 -〉2.用户控件的Page_Load函数 -〉3.用户控件的事件 -〉4.页面的事件。
你是在第4步中赋值的,已经晚了。
if(Session["test"]!=null)
{
string test = Session["test"].ToString();
}
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
} public string Text1 {
get{ return this.TextBox1.Text; }
} public string Text2 {
get{ return this.TextBox2.Text; }
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
Server.Transfer("WebForm2.aspx");
} public class WebForm2 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
WebForm1 wf1;
wf1 = (WebForm1)Context.Handler; Response.Write(wf1.Text1 + wf1.Text2);
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
并且你的那段文字是写在一个诸如<div>的区块中的,那么你可以这样赋值
用JAVASCRIPT:
window.form1.mytext.value=yourdiv.innerText;