Odd web control problem. Two instances of control A on different pages display each other's data!

Discussion in 'ASP .Net Building Controls' started by ~~~ .NET Ed ~~~, Nov 24, 2004.

  1. I am currently using the ScottWatter (or ScottWater) Amazon Book Control in
    a website I am developing. Basically this is the outline:

    - It is a custom web control with designer support
    - Does not depend on any other library with the exception of a few Framework
    (System.Data,.XML,.Designer) libraries.
    - You control it by telling it (via a property) the path to the XML
    configuration file.
    - The control registers its XML configuration file as a response file
    dependency
    - The control has ViewState disabled because it does not need to remember
    any information during PostBacks

    It uses the configuration file to select a random book from the list and
    display it. Pretty simple really. So what is the problem?

    An odd one but I may be missing something. This BookControl is used in two
    different pages of the website. Each
    instance is on a *different* page, Each instance was assigned the
    "BookControl1" ID by vs.net. Each control is given a *different*
    configuration file, i.e BookControl1 on page A is about Technical books, and
    BookControl1 on page B is about Fiction.

    The problem here is that even though the controls are on *different* pages,
    some times the control on Page B starts selecting books from the control on
    Page A and viceversa!!!! this is very strange because they are on different
    pages (have I stressed that enough?) and have no idea about the other
    control's configuration file.

    Is it possible that the web control IDs (BookControl1 in this case) need to
    be UNIQUE across a site and not just a page?, meaning I cannot have two
    controls named BookControl1 in the same ASP.NET application as a whole?.
    This means that if you have it 20 times on 20 different pages you have to
    keep track of that yourself because Visual Studio will always assign it a
    name BookControl1 every time it is the "first" control of that kind on a
    page.

    Any feedback on this is welcome, I find it odd but I could be missing some
    ASP.NET small letters some place ;)

    Thanks in advance
    Em.
    ~~~ .NET Ed ~~~, Nov 24, 2004
    #1
    1. Advertising

  2. Even more odd (?), I gave them different names:
    Page A: BookControl1 book selector file: X.xml
    Page B: BookControl2 book selector file: Y.xml

    And now, not only does the problem still persists, now every now and then
    the control disappears completely from the rendered page... That never
    happened b4, and the DLL containing the control (or the code of the control)
    have not even changed.

    I am really puzzled by this behaviour.

    "~~~ .NET Ed ~~~" <> wrote in message
    news:...
    >I am currently using the ScottWatter (or ScottWater) Amazon Book Control in
    >a website I am developing. Basically this is the outline:
    >
    > - It is a custom web control with designer support
    > - Does not depend on any other library with the exception of a few
    > Framework (System.Data,.XML,.Designer) libraries.
    > - You control it by telling it (via a property) the path to the XML
    > configuration file.
    > - The control registers its XML configuration file as a response file
    > dependency
    > - The control has ViewState disabled because it does not need to remember
    > any information during PostBacks
    >
    > It uses the configuration file to select a random book from the list and
    > display it. Pretty simple really. So what is the problem?
    >
    > An odd one but I may be missing something. This BookControl is used in two
    > different pages of the website. Each
    > instance is on a *different* page, Each instance was assigned the
    > "BookControl1" ID by vs.net. Each control is given a *different*
    > configuration file, i.e BookControl1 on page A is about Technical books,
    > and BookControl1 on page B is about Fiction.
    >
    > The problem here is that even though the controls are on *different*
    > pages, some times the control on Page B starts selecting books from the
    > control on Page A and viceversa!!!! this is very strange because they are
    > on different pages (have I stressed that enough?) and have no idea about
    > the other control's configuration file.
    >
    > Is it possible that the web control IDs (BookControl1 in this case) need
    > to be UNIQUE across a site and not just a page?, meaning I cannot have two
    > controls named BookControl1 in the same ASP.NET application as a whole?.
    > This means that if you have it 20 times on 20 different pages you have to
    > keep track of that yourself because Visual Studio will always assign it a
    > name BookControl1 every time it is the "first" control of that kind on a
    > page.
    >
    > Any feedback on this is welcome, I find it odd but I could be missing some
    > ASP.NET small letters some place ;)
    >
    > Thanks in advance
    > Em.
    >
    ~~~ .NET Ed ~~~, Nov 24, 2004
    #2
    1. Advertising

  3. Got hold on the source again. The author was using Context.Cache with the ID
    and that was causing the controls to jump on each other's toes.

    "~~~ .NET Ed ~~~" <> wrote in message
    news:...
    >I am currently using the ScottWatter (or ScottWater) Amazon Book Control in
    >a website I am developing. Basically this is the outline:
    >
    > - It is a custom web control with designer support
    > - Does not depend on any other library with the exception of a few
    > Framework (System.Data,.XML,.Designer) libraries.
    > - You control it by telling it (via a property) the path to the XML
    > configuration file.
    > - The control registers its XML configuration file as a response file
    > dependency
    > - The control has ViewState disabled because it does not need to remember
    > any information during PostBacks
    >
    > It uses the configuration file to select a random book from the list and
    > display it. Pretty simple really. So what is the problem?
    >
    > An odd one but I may be missing something. This BookControl is used in two
    > different pages of the website. Each
    > instance is on a *different* page, Each instance was assigned the
    > "BookControl1" ID by vs.net. Each control is given a *different*
    > configuration file, i.e BookControl1 on page A is about Technical books,
    > and BookControl1 on page B is about Fiction.
    >
    > The problem here is that even though the controls are on *different*
    > pages, some times the control on Page B starts selecting books from the
    > control on Page A and viceversa!!!! this is very strange because they are
    > on different pages (have I stressed that enough?) and have no idea about
    > the other control's configuration file.
    >
    > Is it possible that the web control IDs (BookControl1 in this case) need
    > to be UNIQUE across a site and not just a page?, meaning I cannot have two
    > controls named BookControl1 in the same ASP.NET application as a whole?.
    > This means that if you have it 20 times on 20 different pages you have to
    > keep track of that yourself because Visual Studio will always assign it a
    > name BookControl1 every time it is the "first" control of that kind on a
    > page.
    >
    > Any feedback on this is welcome, I find it odd but I could be missing some
    > ASP.NET small letters some place ;)
    >
    > Thanks in advance
    > Em.
    >
    ~~~ .NET Ed ~~~, Nov 24, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gizmo
    Replies:
    2
    Views:
    276
    Christian Jaeger
    Oct 29, 2003
  2. SHC
    Replies:
    0
    Views:
    377
  3. Kev Jackson
    Replies:
    2
    Views:
    100
  4. Hedgehog
    Replies:
    1
    Views:
    102
    Michael Winter
    Feb 10, 2005
  5. SHC
    Replies:
    6
    Views:
    167
    -Lost
    Mar 29, 2007
Loading...

Share This Page