Dynamically accessing user control's properties
-
I'm trying to access a user controls properties dynamically from within another user control. The user control i'm using is called MultiImageControl and i'm trying to add ImageControl dynamically as well as it's properties. Is this possible? This is the code i'm using:
public partial class MultiImageControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
UserControl mic = new UserControl();
mic = (UserControl)LoadControl("ImageControl.ascx");
Controls.Add(mic);
pnlImage.Controls.Add(mic);Thanks
"Sex is not the answer, it's the question and the answer is yes"
-
I'm trying to access a user controls properties dynamically from within another user control. The user control i'm using is called MultiImageControl and i'm trying to add ImageControl dynamically as well as it's properties. Is this possible? This is the code i'm using:
public partial class MultiImageControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
UserControl mic = new UserControl();
mic = (UserControl)LoadControl("ImageControl.ascx");
Controls.Add(mic);
pnlImage.Controls.Add(mic);Thanks
"Sex is not the answer, it's the question and the answer is yes"
Hi When you say Controls.Add it refres to this.Controls.Add and in your code it will be refrered as MultiImageControl.Controls.Add ..... And againg you are adding "mic" to pnlImage object. Whats this "pnlImage" object ??
Thanks, Arindam D Tewary
-
Hi When you say Controls.Add it refres to this.Controls.Add and in your code it will be refrered as MultiImageControl.Controls.Add ..... And againg you are adding "mic" to pnlImage object. Whats this "pnlImage" object ??
Thanks, Arindam D Tewary
pnlImage is a panel to display the control but i solved the problem thanks. I was being an idiot and wasn't registering the control in my page. :doh: But if you're interested this is what the code looked like in the end:
ImageControl mic = (ImageControl)LoadControl("ImageControl.ascx"); mic.LeadingEdge = "width"; mic.EdgeLength = 120; mic.ContentAreaId = 7; mic.LocalGateway = "GatewayPic.aspx"; mic.IDtype1 = 2; Controls.Add(mic); pnlImage.Controls.Add(mic);
"Sex is not the answer, it's the question and the answer is yes"
-
pnlImage is a panel to display the control but i solved the problem thanks. I was being an idiot and wasn't registering the control in my page. :doh: But if you're interested this is what the code looked like in the end:
ImageControl mic = (ImageControl)LoadControl("ImageControl.ascx"); mic.LeadingEdge = "width"; mic.EdgeLength = 120; mic.ContentAreaId = 7; mic.LocalGateway = "GatewayPic.aspx"; mic.IDtype1 = 2; Controls.Add(mic); pnlImage.Controls.Add(mic);
"Sex is not the answer, it's the question and the answer is yes"
hey .. nice that you have done it by yourself !!! :-D
Thanks, Arindam D Tewary
-
hey .. nice that you have done it by yourself !!! :-D
Thanks, Arindam D Tewary
Thanks, though i was being a bit of a moron about it. Big night last night. haha
"Sex is not the answer, it's the question and the answer is yes"
-
Thanks, though i was being a bit of a moron about it. Big night last night. haha
"Sex is not the answer, it's the question and the answer is yes"
:)
Thanks, Arindam D Tewary