control ids on rendered content pages

Discussion in 'ASP .Net Web Controls' started by Abraham Luna, Sep 2, 2005.

  1. Abraham Luna

    Abraham Luna Guest

    i am using master and content pages in asp.net 2.0

    on the rendered content page the control id is:

    ctl00$ctl00$cphMainContent$cphCustomers$tbName

    i created javascript expecting the id to be tbName. example below

    var strName = document.getElementById("tbName").value;

    is there a setting or something on the page that will just render the normal
    control id instead of ctl00$ctl00$cphMainContent$cphCustomers$tbName

    thank you
     
    Abraham Luna, Sep 2, 2005
    #1
    1. Advertising

  2. Abraham Luna

    Abraham Luna Guest

    correction on original post:
    the id on the rendered content page is:

    ctl00_ctl00_cphMainContent_cphCustomers_tbName

    the one with the $ symbol was the name property

    please help if you can

    "Abraham Luna" <> wrote in message
    news:...
    >i am using master and content pages in asp.net 2.0
    >
    > on the rendered content page the control id is:
    >
    > ctl00$ctl00$cphMainContent$cphCustomers$tbName
    >
    > i created javascript expecting the id to be tbName. example below
    >
    > var strName = document.getElementById("tbName").value;
    >
    > is there a setting or something on the page that will just render the
    > normal control id instead of
    > ctl00$ctl00$cphMainContent$cphCustomers$tbName
    >
    > thank you
    >
     
    Abraham Luna, Sep 2, 2005
    #2
    1. Advertising

  3. Abraham Luna

    clintonG Guest

    There's no setting or such as you surmise and this issue has been giving me
    a hard time too.

    I'm not 100% certain but reading and understanding the control hierarchy as
    expressed when using Trace gives clues.
    For example, "ctl00_ctl00..." suggests nested MasterPages. Is this correct?

    <%= Clinton Gallagher
    METROmilwaukee (sm) "A Regional Information Service"
    NET csgallagher AT metromilwaukee.com
    URL http://metromilwaukee.com/
    URL http://clintongallagher.metromilwaukee.com/




    "Abraham Luna" <> wrote in message
    news:...
    > correction on original post:
    > the id on the rendered content page is:
    >
    > ctl00_ctl00_cphMainContent_cphCustomers_tbName
    >
    > the one with the $ symbol was the name property
    >
    > please help if you can
    >
    > "Abraham Luna" <> wrote in message
    > news:...
    >>i am using master and content pages in asp.net 2.0
    >>
    >> on the rendered content page the control id is:
    >>
    >> ctl00$ctl00$cphMainContent$cphCustomers$tbName
    >>
    >> i created javascript expecting the id to be tbName. example below
    >>
    >> var strName = document.getElementById("tbName").value;
    >>
    >> is there a setting or something on the page that will just render the
    >> normal control id instead of
    >> ctl00$ctl00$cphMainContent$cphCustomers$tbName
    >>
    >> thank you
    >>

    >
    >
     
    clintonG, Sep 2, 2005
    #3
  4. Abraham Luna

    Abraham Luna Guest

    yes it is nested masterpages. there should be a setting to turn that feature
    off, because good programmers wont need asp.net to create unique ids for
    them. i shouldn't have to render the page just to find out what asp.net
    decided to name my controlid and create javascript like this:

    document.getElementById("ctl00_ctl00_cphMainContent_cphCustomers_tbName")

    it just seems unnecessary

    thank you for your answer though


    "clintonG" <> wrote in message
    news:%23XYeVb%...
    > There's no setting or such as you surmise and this issue has been giving
    > me a hard time too.
    >
    > I'm not 100% certain but reading and understanding the control hierarchy
    > as expressed when using Trace gives clues.
    > For example, "ctl00_ctl00..." suggests nested MasterPages. Is this
    > correct?
    >
    > <%= Clinton Gallagher
    > METROmilwaukee (sm) "A Regional Information Service"
    > NET csgallagher AT metromilwaukee.com
    > URL http://metromilwaukee.com/
    > URL http://clintongallagher.metromilwaukee.com/
    >
    >
    >
    >
    > "Abraham Luna" <> wrote in message
    > news:...
    >> correction on original post:
    >> the id on the rendered content page is:
    >>
    >> ctl00_ctl00_cphMainContent_cphCustomers_tbName
    >>
    >> the one with the $ symbol was the name property
    >>
    >> please help if you can
    >>
    >> "Abraham Luna" <> wrote in message
    >> news:...
    >>>i am using master and content pages in asp.net 2.0
    >>>
    >>> on the rendered content page the control id is:
    >>>
    >>> ctl00$ctl00$cphMainContent$cphCustomers$tbName
    >>>
    >>> i created javascript expecting the id to be tbName. example below
    >>>
    >>> var strName = document.getElementById("tbName").value;
    >>>
    >>> is there a setting or something on the page that will just render the
    >>> normal control id instead of
    >>> ctl00$ctl00$cphMainContent$cphCustomers$tbName
    >>>
    >>> thank you
    >>>

    >>
    >>

    >
    >
     
    Abraham Luna, Sep 2, 2005
    #4
  5. Abraham Luna

    clintonG Guest

    You don't understand the way compilers work yet. There has to be some way to
    manage memory and using an id of some schema type is the way computers have
    always functioned. That you can now see some of the internal processes is a
    benefit if you learn to understand what you are looking at.

    While it is possible to do so it is not advisable to reference controls
    using the generated control id. Every time you add or remove controls in the
    page the control tree will change.

    If you explain what objective you hoped to achieve by referencing a control
    using client-side script I may be able to suggest a more practical solution.

    <%= Clinton Gallagher
    METROmilwaukee (sm) "A Regional Information Service"
    NET csgallagher AT metromilwaukee.com
    URL http://metromilwaukee.com/
    URL http://clintongallagher.metromilwaukee.com/


    "Abraham Luna" <> wrote in message
    news:Oodwvp$...
    > yes it is nested masterpages. there should be a setting to turn that
    > feature off, because good programmers wont need asp.net to create unique
    > ids for them. i shouldn't have to render the page just to find out what
    > asp.net decided to name my controlid and create javascript like this:
    >
    > document.getElementById("ctl00_ctl00_cphMainContent_cphCustomers_tbName")
    >
    > it just seems unnecessary
    >
    > thank you for your answer though
    >
    >
    > "clintonG" <> wrote in message
    > news:%23XYeVb%...
    >> There's no setting or such as you surmise and this issue has been giving
    >> me a hard time too.
    >>
    >> I'm not 100% certain but reading and understanding the control hierarchy
    >> as expressed when using Trace gives clues.
    >> For example, "ctl00_ctl00..." suggests nested MasterPages. Is this
    >> correct?
    >>
    >> <%= Clinton Gallagher
    >> METROmilwaukee (sm) "A Regional Information Service"
    >> NET csgallagher AT metromilwaukee.com
    >> URL http://metromilwaukee.com/
    >> URL http://clintongallagher.metromilwaukee.com/
    >>
    >>
    >>
    >>
    >> "Abraham Luna" <> wrote in message
    >> news:...
    >>> correction on original post:
    >>> the id on the rendered content page is:
    >>>
    >>> ctl00_ctl00_cphMainContent_cphCustomers_tbName
    >>>
    >>> the one with the $ symbol was the name property
    >>>
    >>> please help if you can
    >>>
    >>> "Abraham Luna" <> wrote in message
    >>> news:...
    >>>>i am using master and content pages in asp.net 2.0
    >>>>
    >>>> on the rendered content page the control id is:
    >>>>
    >>>> ctl00$ctl00$cphMainContent$cphCustomers$tbName
    >>>>
    >>>> i created javascript expecting the id to be tbName. example below
    >>>>
    >>>> var strName = document.getElementById("tbName").value;
    >>>>
    >>>> is there a setting or something on the page that will just render the
    >>>> normal control id instead of
    >>>> ctl00$ctl00$cphMainContent$cphCustomers$tbName
    >>>>
    >>>> thank you
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    clintonG, Sep 2, 2005
    #5
    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. Replies:
    2
    Views:
    706
    Beat Bolli
    Jun 21, 2005
  2. Ken Fine
    Replies:
    5
    Views:
    489
    Alexey Smirnov
    Sep 4, 2007
  3. Bob
    Replies:
    5
    Views:
    4,845
    clintonG
    Feb 27, 2008
  4. Matt Sokol
    Replies:
    2
    Views:
    390
    Theo Tillotson
    Aug 7, 2003
  5. TJ
    Replies:
    4
    Views:
    366
    Steven Cheng[MSFT]
    Apr 7, 2006
Loading...

Share This Page