Multiple instance problem of Web USer control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sumitmahajan81
    New Member
    • Mar 2008
    • 4

    Multiple instance problem of Web USer control

    I have created a user control and I add multiple instances of the same to a web page. Set its properties. But have different properties but they are not displayed properly.

    Properties of last control being set seems to be getting applied to both of the controls.

    I have added the control statically and setting its properties latter.

    Pls advise.

    Thanks
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Did you give the control different names?
    If you named anything in the webusercontrol, two copies of it would probably have the same name?

    Comment

    • sumitmahajan81
      New Member
      • Mar 2008
      • 4

      #3
      Originally posted by Plater
      Did you give the control different names?
      If you named anything in the webusercontrol, two copies of it would probably have the same name?
      2 controls have different name. I have tried adding them statically nd dynamicaly also as below
      Control cntrl1= LoadControl("~/UserControls/UC1.ascx");
      cntrl1.property 1=value;
      cntrl2.property 2=value;
      cntrl1.UserLoad ();

      Control cntrl2= LoadControl("~/UserControls/UC1.ascx");
      cntrl2.property 1=value;
      cntrl2.property 2=value;
      cntrl2.UserLoad ();


      But when page is loaded properties of first control gets applied. When i debug it i do see diff values in controls.

      Its probably way control is intialized nad loaded. UserLoad function has everything for setting the control properties.

      Thanks in advance

      Comment

      Working...