且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在用户控件中访问aspx页面中的隐藏控件

更新时间:2023-10-11 12:00:46

您可以通过以下方式访问您的用户控件隐藏的文件值



  var  hdn = YourUserControl.FindControl(  yourhiddencontrolid); 







或者你也可以在你的用户控件中创建一个属性,它会返回你隐藏的文件值......





  public   string  HiddenFiledValue {
get {
return myHiddenFiled.Value;
}
set {
myHiddenFiled.Value = value ;
}
}





并在您的父页面中使用该属性,如下所示......

yourusercontrol.HiddenFiledValue

块引用>

你有没有试过这样的,

什么
 HiddenField Info = this.Page.FindControl(MyHiddenField); 



-KR


Hi,

I have a hidden control in a aspx page . I want to get its value in the user control page that binds the aspx page...Please help

your can access your user control hidden filed value by following ways

var hdn = YourUserControl.FindControl("yourhiddencontrolid");




Or you can also create a properties in your user control which is returning your hidden filed value like this...


public string HiddenFiledValue { 
    get{
        return myHiddenFiled.Value;
    }
    set{
        myHiddenFiled.Value = value;
    }
}



and use that property in your parent page like this...

yourusercontrol.HiddenFiledValue 


Have you not tried anything like this,
HiddenField Info = this.Page.FindControl("MyHiddenField");


-KR