如何从父aspx页面访问子用户控制的控制方法 [英] how to access the controls in child user control from parent aspx page

查看:153
本文介绍了如何从父aspx页面访问子用户控制的控制方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会想知道我可以访问我在我的WebUserControl从我父母的aspx页面的文本框控件。我希望用户在texbox在WebUserControl进入的数据,那么preSS保存按钮,这是在父页面和将在SQL Server中保存。

I will like to know how I can access the textbox controls that I have in my WebUserControl from my Parent aspx page. I want that the user enters the data in texbox at the WebUserControl, then press the "Save" button which is in the parent page and the will be saved at SQL Server.

推荐答案

您可以公开的文本框的 WebUserControl 文字 为public。

You can expose the Text of TextBox of WebUserControl as public.

public partial class WebUserControl : System.Web.UI.UserControl
{
    public string MyText
    {
        get { return MyTextBox.Text; }
        set { MyTextBox.Text = value; }
    }
}

WebForm1.aspx.cs中

public partial class WebForm1 : System.Web.UI.Page
{
    protected void Button1_Click(object sender, EventArgs e)
    {
        string value = WebUserControl1.MyText;
    }
}

这篇关于如何从父aspx页面访问子用户控制的控制方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆