1
我有一个webusercontrol内的下拉列表,我想在5页上使用。我想从页面中保存下拉菜单的选定值。访问WebUserControl DropDown所选值
我试着用下面的方法来访问它,但它不工作
Finding and accessing elements of a WebUserControl
在网页它不是不显示获取所选值
问候
我有一个webusercontrol内的下拉列表,我想在5页上使用。我想从页面中保存下拉菜单的选定值。访问WebUserControl DropDown所选值
我试着用下面的方法来访问它,但它不工作
Finding and accessing elements of a WebUserControl
在网页它不是不显示获取所选值
问候
方法正如该答案所示,您应该在用户控件中创建一个方法,该方法将公开您驻留在用户控件中的下拉列表的选定值。
在你WebUserControl(用户控件)的代码隐藏文件,你可以有这样的事情:
public string DropDownSelectedValue
{
get
{
return dropDown.SelectedValue;
}
}
现在你的网页上,你正在使用的用户控件,你应该叫这样的财产这个:
// Assuming you defined your usercontrol with the 'yourUserControl' ID
string selectedValue = yourUserControl.DropDownSelectedValue;
请确保您重建您的usercontrol代码(项目),以便这个新的属性可供您使用。