如何从aspx中的ascx检索值 [英] how to retrieve values from ascx in aspx

查看:80
本文介绍了如何从aspx中的ascx检索值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有ASCX页面,我需要在aspx页面中检索ascx的值.但是我不知道在ascx页面中控件的id是否使用findcontrol方法.请解决我的问题,感谢快速响应.

Hi,

i have ASCX page, and i need to retrieve the values of ascx in aspx page. but i dont know the id''s of the controls in ascx page to use findcontrol method. please solve my problem, quick response appreciated.

推荐答案


尝试使用findcontrol(0)
Hi,
Try using findcontrol(0)


使用属性
在ascx页面上
Use properties
on ascx page
public string textvalue
    {
        get
        {
            return TextBox1.Text;
        }
        set
        { 
         TextBox1.Text = value; 
        }
    }


并在aspx页面上


and on aspx page

string txtvalue=yourcontrol.textvalue;


Mastering Page-UserControl Communication[^]

or

//like this way to findout
 foreach (Control c in form1.Controls)
        {
            if (c.GetType ( ).Name.ToLower ( ) == "webusercontrol_ascx")
            {
                UserControl uc = (UserControl)c;

                txt = (TextBox)uc.FindControl ( "txtShip" );
            }
        }



编码愉快……



Happy coding......


这篇关于如何从aspx中的ascx检索值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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