_ctl5:_ctl0:p1456 in webform textbox

Discussion in 'ASP .Net Web Controls' started by Steve Steve, Feb 18, 2004.

  1. Steve Steve

    Steve Steve Guest

    Hello

    I've got a bit of a problem here!

    Right, I manage my shopping basket on my shop website by just storing
    the ids and quantities of the products the customer has added in the
    Session - the textbox name that I use in product view to add a quantity
    is a "P" and the itemid to pass to the next page - because there are
    variants of the same product I have to create these rows in code but
    when they submit they append "_ctl5:_ctl0:" to the beginning in the URL.
    This isn't really a problem in itself as long as this remains the same
    so when I come to request I can check for:
    Request.QueryString["_ctl5:_ctl0:p4321"] for example to get at the
    quantity value. 'P' followed by the id of '4321' so in the url I might
    have expected &p4321=100 if a customer selected 100 quantity.

    Right that explained - here is my problem - for the second time now this
    "_ctl5:_ctl0:" has changed - this time to "_ctl4:_ctl0:" spontaneously
    and it isn't the first time it's happened! That means that from a fully
    functional basket all of a sudden I get server errors because the id
    passed from textbox has changed.

    My Question then is can this appendation be altered or bypassed
    altogether so that this problem goes away?

    Thanks
    Steve


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Steve Steve, Feb 18, 2004
    #1
    1. Advertising

  2. Steve Steve

    Steve Steve Guest

    I've managed to fix this on my application but not to my satisfaction -
    it seems the field that is causing my problem is an HtmlInputHidden
    which we set server side - I create the hidden like this in html

    <input type="hidden" id="recno" name="recno" runat="server">

    i.e. I set no value but runat=server so I can set it in code.

    When the control is then created on the page the prefix is already there
    - I assume it must be something to do with running it at server?

    My solution is to store the prefix in the session when a control using
    it is created (from base.UniqueId) and then the Session variable is
    available when I need it. The problem with this is that I'm building a
    site where the Session needs to be kept to a minimum to preserve RAM as
    one of the requirements and I'm loathed to add more variables to it than
    needed.

    If anybody knows how to remove this prefix altogether when the control
    is created could you please post and then I can get rid of the extra
    Session var?

    I have read about someone subclassing the radiobutton they were
    including and overriding the UniqueId of the control they were creating
    but I'm not sure where to start with this - any insight would be
    appreciated.

    Thanks
    Steve


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Steve Steve, Feb 19, 2004
    #2
    1. Advertising

  3. hi steve, your controls are put in that namespace because they are child
    controls. This is necessary to maintain unique ids through your page.

    To remove the prefix you need to remove the control from within the
    container(parent control) you placed it in.



    "Steve Steve" <> wrote in message
    news:%...
    > I've managed to fix this on my application but not to my satisfaction -
    > it seems the field that is causing my problem is an HtmlInputHidden
    > which we set server side - I create the hidden like this in html
    >
    > <input type="hidden" id="recno" name="recno" runat="server">
    >
    > i.e. I set no value but runat=server so I can set it in code.
    >
    > When the control is then created on the page the prefix is already there
    > - I assume it must be something to do with running it at server?
    >
    > My solution is to store the prefix in the session when a control using
    > it is created (from base.UniqueId) and then the Session variable is
    > available when I need it. The problem with this is that I'm building a
    > site where the Session needs to be kept to a minimum to preserve RAM as
    > one of the requirements and I'm loathed to add more variables to it than
    > needed.
    >
    > If anybody knows how to remove this prefix altogether when the control
    > is created could you please post and then I can get rid of the extra
    > Session var?
    >
    > I have read about someone subclassing the radiobutton they were
    > including and overriding the UniqueId of the control they were creating
    > but I'm not sure where to start with this - any insight would be
    > appreciated.
    >
    > Thanks
    > Steve
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Alessandro Zifiglio, Feb 19, 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. Hazzard
    Replies:
    2
    Views:
    532
    Yan-Hong Huang[MSFT]
    Jul 23, 2003
  2. Natty Gur
    Replies:
    0
    Views:
    449
    Natty Gur
    Jul 22, 2003
  3. Anders Borum
    Replies:
    2
    Views:
    2,514
    Anders Borum
    Nov 26, 2003
  4. news.microsoft.com

    Id is changed on my server control! (_ctl5)

    news.microsoft.com, Jul 15, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    401
    John Saunders
    Jul 15, 2004
  5. DFB

    Automatic Control Prefixes like _ctl0

    DFB, Sep 21, 2005, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    191
Loading...

Share This Page