Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Dynamically accessing user control's properties

Dynamically accessing user control's properties

Scheduled Pinned Locked Moved ASP.NET
questionwinformsdesign
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    windhopper
    wrote on last edited by
    #1

    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"

    A 1 Reply Last reply
    0
    • W windhopper

      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"

      A Offline
      A Offline
      Arindam Tewary
      wrote on last edited by
      #2

      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

      W 1 Reply Last reply
      0
      • A Arindam 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

        W Offline
        W Offline
        windhopper
        wrote on last edited by
        #3

        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"

        A 1 Reply Last reply
        0
        • W windhopper

          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"

          A Offline
          A Offline
          Arindam Tewary
          wrote on last edited by
          #4

          hey .. nice that you have done it by yourself !!! :-D

          Thanks, Arindam D Tewary

          W 1 Reply Last reply
          0
          • A Arindam Tewary

            hey .. nice that you have done it by yourself !!! :-D

            Thanks, Arindam D Tewary

            W Offline
            W Offline
            windhopper
            wrote on last edited by
            #5

            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"

            A 1 Reply Last reply
            0
            • W windhopper

              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"

              A Offline
              A Offline
              Arindam Tewary
              wrote on last edited by
              #6

              :)

              Thanks, Arindam D Tewary

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups