C# 从用户控件中查找图像控件

C# 从用户控件中查找图像控件,c#,asp.net,user-controls,C#,Asp.net,User Controls,我对ASP和C很陌生。 我有一个用户控件,它有两个单选按钮和图像控件。 我希望在单击按钮时动态加载此控件,同时为图像控件提供ImageURL。 文件上传在aspx页面上。 有人能帮我吗 Control MyUserControl=LoadControl(“MyControl.ascx”);占位符1.Controls.Add(MyUserControl) 我能够加载用户控件。 现在介绍如何提供imageURL 提前感谢。公开MyControl.ascx中的图像URL 然后将MyUserContro

我对ASP和C很陌生。 我有一个用户控件,它有两个单选按钮和图像控件。 我希望在单击按钮时动态加载此控件,同时为图像控件提供ImageURL。 文件上传在aspx页面上。 有人能帮我吗

Control MyUserControl=LoadControl(“MyControl.ascx”);占位符1.Controls.Add(MyUserControl)

我能够加载用户控件。 现在介绍如何提供imageURL


提前感谢。

公开MyControl.ascx中的图像URL 然后将MyUserControl强制转换为usercontrol并分配图像 例如:

Control MyUserControl1 = LoadControl("MyControl.ascx");
MyUserControl temp = (MyUserControl) MyUserControl1;
temp.ImageURL = "urlhere.jpg";

将MyControl.ascx中的图像URL公开为公共 然后将MyUserControl强制转换为usercontrol并分配图像 例如:

Control MyUserControl1 = LoadControl("MyControl.ascx");
MyUserControl temp = (MyUserControl) MyUserControl1;
temp.ImageURL = "urlhere.jpg";

我添加了您的代码,但它给出了一个错误,找不到类型或命名空间名称“MyUserControl”(您是否缺少using指令或程序集引用?)。问题在于
作为MyUserControl
,您需要引用已在其中定义了
MyUserControl
的命名空间。我添加了您的代码,但出现了一个错误,无法找到类型或命名空间名称“MyUserControl”(您是否缺少using指令或程序集引用?)问题在于
作为MyUserControl
,您需要引用您在其中定义的命名空间
MyUserControl
Hi John Kenedy,如何公开图像URL?Hi John Kenedy,如何公开图像URL??