altering .UniqueID

Discussion in 'ASP .Net' started by jason.hau@gmail.com, Sep 22, 2006.

  1. Guest

    Is there any way to alter this? I am aware that it's read only.
    Essentially the problem is that I have a webcontrol that dynamically
    creates a textbox and a requiredfieldvalidator control with the
    validator validating the textbox. This worked fine in my test harness
    and works fine in my other projects using master page based pages when
    in IE but in Firefox, the other project doesn't work. I've been able to
    narrow it down to teh fact that we've got a preappend on the ID of the
    controls of "_ctl0" and as an underscore isn't a valid start character,
    firefox doesn't run the javascript (quite rightly).
    I'd prefer to alter this within the original code that creates the sub
    controls rather than hack it in the other project as it's to be part of
    a common library for use elsewhere.
    , Sep 22, 2006
    #1
    1. Advertising

  2. Can you try the name tag instead?


    <> schreef in bericht
    news:...
    > Is there any way to alter this? I am aware that it's read only.
    > Essentially the problem is that I have a webcontrol that dynamically
    > creates a textbox and a requiredfieldvalidator control with the
    > validator validating the textbox. This worked fine in my test harness
    > and works fine in my other projects using master page based pages when
    > in IE but in Firefox, the other project doesn't work. I've been able to
    > narrow it down to teh fact that we've got a preappend on the ID of the
    > controls of "_ctl0" and as an underscore isn't a valid start character,
    > firefox doesn't run the javascript (quite rightly).
    > I'd prefer to alter this within the original code that creates the sub
    > controls rather than hack it in the other project as it's to be part of
    > a common library for use elsewhere.
    >
    Edwin Knoppert, Sep 22, 2006
    #2
    1. Advertising

  3. RVB Guest

    Not really an option, the validators work by writing a javascript array
    called Page_Validators, automatically generated by .NET itself. This is
    then referenced by another automatically generated item, a javascript
    file, which it pulls out using a handler via
    webresource.axd?somerandomguid. As such, can't really alter the
    javascript call itself where the validation fires off nor is it really
    practical to try and reverse engineer this js file.
    I have found another ID reference: ClientID but again, read only. The
    only one which you appera to be able to alter is ID which is of no use
    whatsoever. All I want is to be able to change the ID, I fail to
    understand why this is so hard, especially as I keep hearing "oh yes,
    validators have been fixed to work with Firefox in .NET 2.0".
    BTW, Test Harness works in Firefox because it lacks the auto
    pre-append. I'm not exactly sure where this auto generated _ctl0 is
    coming from. Admittedly the control sits inside an ascx (which has a
    normal id) and then itself with a contentplaceholder based off a
    seperate master page. If I knew where that was coming from I would be
    able to override it but the control has an ID, the placeholder has an
    ID and I'm at a loss to determine why it's appearing.
    Edwin Knoppert wrote:
    > Can you try the name tag instead?
    >
    >
    > <> schreef in bericht
    > news:...
    > > Is there any way to alter this? I am aware that it's read only.
    > > Essentially the problem is that I have a webcontrol that dynamically
    > > creates a textbox and a requiredfieldvalidator control with the
    > > validator validating the textbox. This worked fine in my test harness
    > > and works fine in my other projects using master page based pages when
    > > in IE but in Firefox, the other project doesn't work. I've been able to
    > > narrow it down to teh fact that we've got a preappend on the ID of the
    > > controls of "_ctl0" and as an underscore isn't a valid start character,
    > > firefox doesn't run the javascript (quite rightly).
    > > I'd prefer to alter this within the original code that creates the sub
    > > controls rather than hack it in the other project as it's to be part of
    > > a common library for use elsewhere.
    > >
    RVB, Sep 22, 2006
    #3
  4. I don't have ff installed but i often needed to use document.GetEl.. ByID(
    'name of control') to get an object refer.
    Is the quoted way not a solution?




    "RVB" <> schreef in bericht
    news:...
    > Not really an option, the validators work by writing a javascript array
    > called Page_Validators, automatically generated by .NET itself. This is
    > then referenced by another automatically generated item, a javascript
    > file, which it pulls out using a handler via
    > webresource.axd?somerandomguid. As such, can't really alter the
    > javascript call itself where the validation fires off nor is it really
    > practical to try and reverse engineer this js file.
    > I have found another ID reference: ClientID but again, read only. The
    > only one which you appera to be able to alter is ID which is of no use
    > whatsoever. All I want is to be able to change the ID, I fail to
    > understand why this is so hard, especially as I keep hearing "oh yes,
    > validators have been fixed to work with Firefox in .NET 2.0".
    > BTW, Test Harness works in Firefox because it lacks the auto
    > pre-append. I'm not exactly sure where this auto generated _ctl0 is
    > coming from. Admittedly the control sits inside an ascx (which has a
    > normal id) and then itself with a contentplaceholder based off a
    > seperate master page. If I knew where that was coming from I would be
    > able to override it but the control has an ID, the placeholder has an
    > ID and I'm at a loss to determine why it's appearing.
    > Edwin Knoppert wrote:
    >> Can you try the name tag instead?
    >>
    >>
    >> <> schreef in bericht
    >> news:...
    >> > Is there any way to alter this? I am aware that it's read only.
    >> > Essentially the problem is that I have a webcontrol that dynamically
    >> > creates a textbox and a requiredfieldvalidator control with the
    >> > validator validating the textbox. This worked fine in my test harness
    >> > and works fine in my other projects using master page based pages when
    >> > in IE but in Firefox, the other project doesn't work. I've been able to
    >> > narrow it down to teh fact that we've got a preappend on the ID of the
    >> > controls of "_ctl0" and as an underscore isn't a valid start character,
    >> > firefox doesn't run the javascript (quite rightly).
    >> > I'd prefer to alter this within the original code that creates the sub
    >> > controls rather than hack it in the other project as it's to be part of
    >> > a common library for use elsewhere.
    >> >

    >
    Edwin Knoppert, Sep 22, 2006
    #4
  5. Like:
    var o = document.getElementById('<%=txt_Index.ClientID%>');
    o.value = ....


    "RVB" <> schreef in bericht
    news:...
    > Not really an option, the validators work by writing a javascript array
    > called Page_Validators, automatically generated by .NET itself. This is
    > then referenced by another automatically generated item, a javascript
    > file, which it pulls out using a handler via
    > webresource.axd?somerandomguid. As such, can't really alter the
    > javascript call itself where the validation fires off nor is it really
    > practical to try and reverse engineer this js file.
    > I have found another ID reference: ClientID but again, read only. The
    > only one which you appera to be able to alter is ID which is of no use
    > whatsoever. All I want is to be able to change the ID, I fail to
    > understand why this is so hard, especially as I keep hearing "oh yes,
    > validators have been fixed to work with Firefox in .NET 2.0".
    > BTW, Test Harness works in Firefox because it lacks the auto
    > pre-append. I'm not exactly sure where this auto generated _ctl0 is
    > coming from. Admittedly the control sits inside an ascx (which has a
    > normal id) and then itself with a contentplaceholder based off a
    > seperate master page. If I knew where that was coming from I would be
    > able to override it but the control has an ID, the placeholder has an
    > ID and I'm at a loss to determine why it's appearing.
    > Edwin Knoppert wrote:
    >> Can you try the name tag instead?
    >>
    >>
    >> <> schreef in bericht
    >> news:...
    >> > Is there any way to alter this? I am aware that it's read only.
    >> > Essentially the problem is that I have a webcontrol that dynamically
    >> > creates a textbox and a requiredfieldvalidator control with the
    >> > validator validating the textbox. This worked fine in my test harness
    >> > and works fine in my other projects using master page based pages when
    >> > in IE but in Firefox, the other project doesn't work. I've been able to
    >> > narrow it down to teh fact that we've got a preappend on the ID of the
    >> > controls of "_ctl0" and as an underscore isn't a valid start character,
    >> > firefox doesn't run the javascript (quite rightly).
    >> > I'd prefer to alter this within the original code that creates the sub
    >> > controls rather than hack it in the other project as it's to be part of
    >> > a common library for use elsewhere.
    >> >

    >
    Edwin Knoppert, Sep 22, 2006
    #5
  6. RVB Guest

    As far as I'm aware, it's not, reason being that the actual javascript
    array creation is done by the .NET framework automatically if it
    detects that there are validators in the validator collection. It is
    doing essentially the same as your snippet, it just outputs the actual
    clientid for the validator control (at that point rendered as a span)
    instead of doing a codebehind call. I can't actually get alter this
    array and in any case, it wouldn't work because of the actual format of
    the ID:
    Using your example, "txt_Index.ClientID" would equate to
    "_ctl0_txt_Index1". As it starts with an underscore, firefox doesn't
    recognize it as a correct ID. So, as you can see, the problem stems
    from the whole auto-generation of the clientID. Fix that and you'd be
    laughing.
    Several other people have apparently got around this by doing
    control.ClientID = control.ClientID.Replace("_","") but I find that
    highly unlikely as you -cannot- set the ClientID property, nor the
    UniqueID.

    Edwin Knoppert wrote:
    > Like:
    > var o = document.getElementById('<%=txt_Index.ClientID%>');
    > o.value = ....
    >
    >
    > "RVB" <> schreef in bericht
    > news:...
    > > Not really an option, the validators work by writing a javascript array
    > > called Page_Validators, automatically generated by .NET itself. This is
    > > then referenced by another automatically generated item, a javascript
    > > file, which it pulls out using a handler via
    > > webresource.axd?somerandomguid. As such, can't really alter the
    > > javascript call itself where the validation fires off nor is it really
    > > practical to try and reverse engineer this js file.
    > > I have found another ID reference: ClientID but again, read only. The
    > > only one which you appera to be able to alter is ID which is of no use
    > > whatsoever. All I want is to be able to change the ID, I fail to
    > > understand why this is so hard, especially as I keep hearing "oh yes,
    > > validators have been fixed to work with Firefox in .NET 2.0".
    > > BTW, Test Harness works in Firefox because it lacks the auto
    > > pre-append. I'm not exactly sure where this auto generated _ctl0 is
    > > coming from. Admittedly the control sits inside an ascx (which has a
    > > normal id) and then itself with a contentplaceholder based off a
    > > seperate master page. If I knew where that was coming from I would be
    > > able to override it but the control has an ID, the placeholder has an
    > > ID and I'm at a loss to determine why it's appearing.
    > > Edwin Knoppert wrote:
    > >> Can you try the name tag instead?
    > >>
    > >>
    > >> <> schreef in bericht
    > >> news:...
    > >> > Is there any way to alter this? I am aware that it's read only.
    > >> > Essentially the problem is that I have a webcontrol that dynamically
    > >> > creates a textbox and a requiredfieldvalidator control with the
    > >> > validator validating the textbox. This worked fine in my test harness
    > >> > and works fine in my other projects using master page based pages when
    > >> > in IE but in Firefox, the other project doesn't work. I've been able to
    > >> > narrow it down to teh fact that we've got a preappend on the ID of the
    > >> > controls of "_ctl0" and as an underscore isn't a valid start character,
    > >> > firefox doesn't run the javascript (quite rightly).
    > >> > I'd prefer to alter this within the original code that creates the sub
    > >> > controls rather than hack it in the other project as it's to be part of
    > >> > a common library for use elsewhere.
    > >> >

    > >
    RVB, Sep 22, 2006
    #6
  7. I had the thought the quoted situation might have helped
    (getElementById('...')
    Have you actually tried this approach?


    "RVB" <> schreef in bericht
    news:...
    > As far as I'm aware, it's not, reason being that the actual javascript
    > array creation is done by the .NET framework automatically if it
    > detects that there are validators in the validator collection. It is
    > doing essentially the same as your snippet, it just outputs the actual
    > clientid for the validator control (at that point rendered as a span)
    > instead of doing a codebehind call. I can't actually get alter this
    > array and in any case, it wouldn't work because of the actual format of
    > the ID:
    > Using your example, "txt_Index.ClientID" would equate to
    > "_ctl0_txt_Index1". As it starts with an underscore, firefox doesn't
    > recognize it as a correct ID. So, as you can see, the problem stems
    > from the whole auto-generation of the clientID. Fix that and you'd be
    > laughing.
    > Several other people have apparently got around this by doing
    > control.ClientID = control.ClientID.Replace("_","") but I find that
    > highly unlikely as you -cannot- set the ClientID property, nor the
    > UniqueID.
    >
    > Edwin Knoppert wrote:
    >> Like:
    >> var o = document.getElementById('<%=txt_Index.ClientID%>');
    >> o.value = ....
    >>
    >>
    >> "RVB" <> schreef in bericht
    >> news:...
    >> > Not really an option, the validators work by writing a javascript array
    >> > called Page_Validators, automatically generated by .NET itself. This is
    >> > then referenced by another automatically generated item, a javascript
    >> > file, which it pulls out using a handler via
    >> > webresource.axd?somerandomguid. As such, can't really alter the
    >> > javascript call itself where the validation fires off nor is it really
    >> > practical to try and reverse engineer this js file.
    >> > I have found another ID reference: ClientID but again, read only. The
    >> > only one which you appera to be able to alter is ID which is of no use
    >> > whatsoever. All I want is to be able to change the ID, I fail to
    >> > understand why this is so hard, especially as I keep hearing "oh yes,
    >> > validators have been fixed to work with Firefox in .NET 2.0".
    >> > BTW, Test Harness works in Firefox because it lacks the auto
    >> > pre-append. I'm not exactly sure where this auto generated _ctl0 is
    >> > coming from. Admittedly the control sits inside an ascx (which has a
    >> > normal id) and then itself with a contentplaceholder based off a
    >> > seperate master page. If I knew where that was coming from I would be
    >> > able to override it but the control has an ID, the placeholder has an
    >> > ID and I'm at a loss to determine why it's appearing.
    >> > Edwin Knoppert wrote:
    >> >> Can you try the name tag instead?
    >> >>
    >> >>
    >> >> <> schreef in bericht
    >> >> news:...
    >> >> > Is there any way to alter this? I am aware that it's read only.
    >> >> > Essentially the problem is that I have a webcontrol that dynamically
    >> >> > creates a textbox and a requiredfieldvalidator control with the
    >> >> > validator validating the textbox. This worked fine in my test
    >> >> > harness
    >> >> > and works fine in my other projects using master page based pages
    >> >> > when
    >> >> > in IE but in Firefox, the other project doesn't work. I've been able
    >> >> > to
    >> >> > narrow it down to teh fact that we've got a preappend on the ID of
    >> >> > the
    >> >> > controls of "_ctl0" and as an underscore isn't a valid start
    >> >> > character,
    >> >> > firefox doesn't run the javascript (quite rightly).
    >> >> > I'd prefer to alter this within the original code that creates the
    >> >> > sub
    >> >> > controls rather than hack it in the other project as it's to be part
    >> >> > of
    >> >> > a common library for use elsewhere.
    >> >> >
    >> >

    >
    Edwin Knoppert, Sep 25, 2006
    #7
  8. RVB Guest

    I -cannot- alter the javascript as it is auto-generated and the API
    does not provide me with an entry point to do so.

    I have gotten a touch further, the original _ctrl0 was coming from the
    ID of the Master.ID property on the page itself. When I altered the ID
    of the Page.Master property, I was able to remove the "_" from the
    generated clientID so it ends up as "ctrl0_txtSomething_ctrl1" which,
    as far as I can see is definately a valid ID which can be passed to the
    document.getElementById function. However, still doesn't work.

    Additionally, I've crossposted to the javascript newsgroup but has
    anyone hit this before in .NET?

    Edwin Knoppert wrote:

    > I had the thought the quoted situation might have helped
    > (getElementById('...')
    > Have you actually tried this approach?
    >
    >
    > "RVB" <> schreef in bericht
    > news:...
    > > As far as I'm aware, it's not, reason being that the actual javascript
    > > array creation is done by the .NET framework automatically if it
    > > detects that there are validators in the validator collection. It is
    > > doing essentially the same as your snippet, it just outputs the actual
    > > clientid for the validator control (at that point rendered as a span)
    > > instead of doing a codebehind call. I can't actually get alter this
    > > array and in any case, it wouldn't work because of the actual format of
    > > the ID:
    > > Using your example, "txt_Index.ClientID" would equate to
    > > "_ctl0_txt_Index1". As it starts with an underscore, firefox doesn't
    > > recognize it as a correct ID. So, as you can see, the problem stems
    > > from the whole auto-generation of the clientID. Fix that and you'd be
    > > laughing.
    > > Several other people have apparently got around this by doing
    > > control.ClientID = control.ClientID.Replace("_","") but I find that
    > > highly unlikely as you -cannot- set the ClientID property, nor the
    > > UniqueID.
    > >
    > > Edwin Knoppert wrote:
    > >> Like:
    > >> var o = document.getElementById('<%=txt_Index.ClientID%>');
    > >> o.value = ....
    > >>
    > >>
    > >> "RVB" <> schreef in bericht
    > >> news:...
    > >> > Not really an option, the validators work by writing a javascript array
    > >> > called Page_Validators, automatically generated by .NET itself. This is
    > >> > then referenced by another automatically generated item, a javascript
    > >> > file, which it pulls out using a handler via
    > >> > webresource.axd?somerandomguid. As such, can't really alter the
    > >> > javascript call itself where the validation fires off nor is it really
    > >> > practical to try and reverse engineer this js file.
    > >> > I have found another ID reference: ClientID but again, read only. The
    > >> > only one which you appera to be able to alter is ID which is of no use
    > >> > whatsoever. All I want is to be able to change the ID, I fail to
    > >> > understand why this is so hard, especially as I keep hearing "oh yes,
    > >> > validators have been fixed to work with Firefox in .NET 2.0".
    > >> > BTW, Test Harness works in Firefox because it lacks the auto
    > >> > pre-append. I'm not exactly sure where this auto generated _ctl0 is
    > >> > coming from. Admittedly the control sits inside an ascx (which has a
    > >> > normal id) and then itself with a contentplaceholder based off a
    > >> > seperate master page. If I knew where that was coming from I would be
    > >> > able to override it but the control has an ID, the placeholder has an
    > >> > ID and I'm at a loss to determine why it's appearing.
    > >> > Edwin Knoppert wrote:
    > >> >> Can you try the name tag instead?
    > >> >>
    > >> >>
    > >> >> <> schreef in bericht
    > >> >> news:...
    > >> >> > Is there any way to alter this? I am aware that it's read only.
    > >> >> > Essentially the problem is that I have a webcontrol that dynamically
    > >> >> > creates a textbox and a requiredfieldvalidator control with the
    > >> >> > validator validating the textbox. This worked fine in my test
    > >> >> > harness
    > >> >> > and works fine in my other projects using master page based pages
    > >> >> > when
    > >> >> > in IE but in Firefox, the other project doesn't work. I've been able
    > >> >> > to
    > >> >> > narrow it down to teh fact that we've got a preappend on the ID of
    > >> >> > the
    > >> >> > controls of "_ctl0" and as an underscore isn't a valid start
    > >> >> > character,
    > >> >> > firefox doesn't run the javascript (quite rightly).
    > >> >> > I'd prefer to alter this within the original code that creates the
    > >> >> > sub
    > >> >> > controls rather than hack it in the other project as it's to be part
    > >> >> > of
    > >> >> > a common library for use elsewhere.
    > >> >> >
    > >> >

    > >
    RVB, Sep 25, 2006
    #8
  9. >I -cannot- alter the javascript as it is auto-generated and the API does
    >not provide me with an entry point to do so.


    That was not my point.
    I asked if you tried to obtain an object using this getElementById('...')
    often people directly refer to a control in js, which not always works.
    Obtaining a refer to the control using getElementById('...') is imo better.

    So.. a simple:
    alert( getElementById(' your clientid stuff here ') );

    Does that result in an object or null?


    "RVB" <> schreef in bericht
    news:...
    >I -cannot- alter the javascript as it is auto-generated and the API
    > does not provide me with an entry point to do so.
    >
    > I have gotten a touch further, the original _ctrl0 was coming from the
    > ID of the Master.ID property on the page itself. When I altered the ID
    > of the Page.Master property, I was able to remove the "_" from the
    > generated clientID so it ends up as "ctrl0_txtSomething_ctrl1" which,
    > as far as I can see is definately a valid ID which can be passed to the
    > document.getElementById function. However, still doesn't work.
    >
    > Additionally, I've crossposted to the javascript newsgroup but has
    > anyone hit this before in .NET?
    >
    > Edwin Knoppert wrote:
    >
    >> I had the thought the quoted situation might have helped
    >> (getElementById('...')
    >> Have you actually tried this approach?
    >>
    >>
    >> "RVB" <> schreef in bericht
    >> news:...
    >> > As far as I'm aware, it's not, reason being that the actual javascript
    >> > array creation is done by the .NET framework automatically if it
    >> > detects that there are validators in the validator collection. It is
    >> > doing essentially the same as your snippet, it just outputs the actual
    >> > clientid for the validator control (at that point rendered as a span)
    >> > instead of doing a codebehind call. I can't actually get alter this
    >> > array and in any case, it wouldn't work because of the actual format of
    >> > the ID:
    >> > Using your example, "txt_Index.ClientID" would equate to
    >> > "_ctl0_txt_Index1". As it starts with an underscore, firefox doesn't
    >> > recognize it as a correct ID. So, as you can see, the problem stems
    >> > from the whole auto-generation of the clientID. Fix that and you'd be
    >> > laughing.
    >> > Several other people have apparently got around this by doing
    >> > control.ClientID = control.ClientID.Replace("_","") but I find that
    >> > highly unlikely as you -cannot- set the ClientID property, nor the
    >> > UniqueID.
    >> >
    >> > Edwin Knoppert wrote:
    >> >> Like:
    >> >> var o = document.getElementById('<%=txt_Index.ClientID%>');
    >> >> o.value = ....
    >> >>
    >> >>
    >> >> "RVB" <> schreef in bericht
    >> >> news:...
    >> >> > Not really an option, the validators work by writing a javascript
    >> >> > array
    >> >> > called Page_Validators, automatically generated by .NET itself. This
    >> >> > is
    >> >> > then referenced by another automatically generated item, a
    >> >> > javascript
    >> >> > file, which it pulls out using a handler via
    >> >> > webresource.axd?somerandomguid. As such, can't really alter the
    >> >> > javascript call itself where the validation fires off nor is it
    >> >> > really
    >> >> > practical to try and reverse engineer this js file.
    >> >> > I have found another ID reference: ClientID but again, read only.
    >> >> > The
    >> >> > only one which you appera to be able to alter is ID which is of no
    >> >> > use
    >> >> > whatsoever. All I want is to be able to change the ID, I fail to
    >> >> > understand why this is so hard, especially as I keep hearing "oh
    >> >> > yes,
    >> >> > validators have been fixed to work with Firefox in .NET 2.0".
    >> >> > BTW, Test Harness works in Firefox because it lacks the auto
    >> >> > pre-append. I'm not exactly sure where this auto generated _ctl0 is
    >> >> > coming from. Admittedly the control sits inside an ascx (which has a
    >> >> > normal id) and then itself with a contentplaceholder based off a
    >> >> > seperate master page. If I knew where that was coming from I would
    >> >> > be
    >> >> > able to override it but the control has an ID, the placeholder has
    >> >> > an
    >> >> > ID and I'm at a loss to determine why it's appearing.
    >> >> > Edwin Knoppert wrote:
    >> >> >> Can you try the name tag instead?
    >> >> >>
    >> >> >>
    >> >> >> <> schreef in bericht
    >> >> >> news:...
    >> >> >> > Is there any way to alter this? I am aware that it's read only.
    >> >> >> > Essentially the problem is that I have a webcontrol that
    >> >> >> > dynamically
    >> >> >> > creates a textbox and a requiredfieldvalidator control with the
    >> >> >> > validator validating the textbox. This worked fine in my test
    >> >> >> > harness
    >> >> >> > and works fine in my other projects using master page based pages
    >> >> >> > when
    >> >> >> > in IE but in Firefox, the other project doesn't work. I've been
    >> >> >> > able
    >> >> >> > to
    >> >> >> > narrow it down to teh fact that we've got a preappend on the ID
    >> >> >> > of
    >> >> >> > the
    >> >> >> > controls of "_ctl0" and as an underscore isn't a valid start
    >> >> >> > character,
    >> >> >> > firefox doesn't run the javascript (quite rightly).
    >> >> >> > I'd prefer to alter this within the original code that creates
    >> >> >> > the
    >> >> >> > sub
    >> >> >> > controls rather than hack it in the other project as it's to be
    >> >> >> > part
    >> >> >> > of
    >> >> >> > a common library for use elsewhere.
    >> >> >> >
    >> >> >
    >> >

    >
    Edwin Knoppert, Sep 26, 2006
    #9
  10. RVB Guest

    Sorry for the mix up.
    I've actually got a touch further in that it now does populate the
    array correctly but the actual validation function isn't being called.
    I've checked with various formats of IDs and it definately wasn't
    picking it up when using an underscore as the beginning character, i.e.
    the array was empty. Got it to output without that beginning underscore
    and it now picks up the elements. Now just seeing why it doesn't
    register the validator.IsValid property as false.


    Edwin Knoppert wrote:
    > >I -cannot- alter the javascript as it is auto-generated and the API does
    > >not provide me with an entry point to do so.

    >
    > That was not my point.
    > I asked if you tried to obtain an object using this getElementById('...')
    > often people directly refer to a control in js, which not always works.
    > Obtaining a refer to the control using getElementById('...') is imo better.
    >
    > So.. a simple:
    > alert( getElementById(' your clientid stuff here ') );
    >
    > Does that result in an object or null?
    >
    >
    > "RVB" <> schreef in bericht
    > news:...
    > >I -cannot- alter the javascript as it is auto-generated and the API
    > > does not provide me with an entry point to do so.
    > >
    > > I have gotten a touch further, the original _ctrl0 was coming from the
    > > ID of the Master.ID property on the page itself. When I altered the ID
    > > of the Page.Master property, I was able to remove the "_" from the
    > > generated clientID so it ends up as "ctrl0_txtSomething_ctrl1" which,
    > > as far as I can see is definately a valid ID which can be passed to the
    > > document.getElementById function. However, still doesn't work.
    > >
    > > Additionally, I've crossposted to the javascript newsgroup but has
    > > anyone hit this before in .NET?
    > >
    > > Edwin Knoppert wrote:
    > >
    > >> I had the thought the quoted situation might have helped
    > >> (getElementById('...')
    > >> Have you actually tried this approach?
    > >>
    > >>
    > >> "RVB" <> schreef in bericht
    > >> news:...
    > >> > As far as I'm aware, it's not, reason being that the actual javascript
    > >> > array creation is done by the .NET framework automatically if it
    > >> > detects that there are validators in the validator collection. It is
    > >> > doing essentially the same as your snippet, it just outputs the actual
    > >> > clientid for the validator control (at that point rendered as a span)
    > >> > instead of doing a codebehind call. I can't actually get alter this
    > >> > array and in any case, it wouldn't work because of the actual format of
    > >> > the ID:
    > >> > Using your example, "txt_Index.ClientID" would equate to
    > >> > "_ctl0_txt_Index1". As it starts with an underscore, firefox doesn't
    > >> > recognize it as a correct ID. So, as you can see, the problem stems
    > >> > from the whole auto-generation of the clientID. Fix that and you'd be
    > >> > laughing.
    > >> > Several other people have apparently got around this by doing
    > >> > control.ClientID = control.ClientID.Replace("_","") but I find that
    > >> > highly unlikely as you -cannot- set the ClientID property, nor the
    > >> > UniqueID.
    > >> >
    > >> > Edwin Knoppert wrote:
    > >> >> Like:
    > >> >> var o = document.getElementById('<%=txt_Index.ClientID%>');
    > >> >> o.value = ....
    > >> >>
    > >> >>
    > >> >> "RVB" <> schreef in bericht
    > >> >> news:...
    > >> >> > Not really an option, the validators work by writing a javascript
    > >> >> > array
    > >> >> > called Page_Validators, automatically generated by .NET itself. This
    > >> >> > is
    > >> >> > then referenced by another automatically generated item, a
    > >> >> > javascript
    > >> >> > file, which it pulls out using a handler via
    > >> >> > webresource.axd?somerandomguid. As such, can't really alter the
    > >> >> > javascript call itself where the validation fires off nor is it
    > >> >> > really
    > >> >> > practical to try and reverse engineer this js file.
    > >> >> > I have found another ID reference: ClientID but again, read only.
    > >> >> > The
    > >> >> > only one which you appera to be able to alter is ID which is of no
    > >> >> > use
    > >> >> > whatsoever. All I want is to be able to change the ID, I fail to
    > >> >> > understand why this is so hard, especially as I keep hearing "oh
    > >> >> > yes,
    > >> >> > validators have been fixed to work with Firefox in .NET 2.0".
    > >> >> > BTW, Test Harness works in Firefox because it lacks the auto
    > >> >> > pre-append. I'm not exactly sure where this auto generated _ctl0 is
    > >> >> > coming from. Admittedly the control sits inside an ascx (which has a
    > >> >> > normal id) and then itself with a contentplaceholder based off a
    > >> >> > seperate master page. If I knew where that was coming from I would
    > >> >> > be
    > >> >> > able to override it but the control has an ID, the placeholder has
    > >> >> > an
    > >> >> > ID and I'm at a loss to determine why it's appearing.
    > >> >> > Edwin Knoppert wrote:
    > >> >> >> Can you try the name tag instead?
    > >> >> >>
    > >> >> >>
    > >> >> >> <> schreef in bericht
    > >> >> >> news:...
    > >> >> >> > Is there any way to alter this? I am aware that it's read only.
    > >> >> >> > Essentially the problem is that I have a webcontrol that
    > >> >> >> > dynamically
    > >> >> >> > creates a textbox and a requiredfieldvalidator control with the
    > >> >> >> > validator validating the textbox. This worked fine in my test
    > >> >> >> > harness
    > >> >> >> > and works fine in my other projects using master page based pages
    > >> >> >> > when
    > >> >> >> > in IE but in Firefox, the other project doesn't work. I've been
    > >> >> >> > able
    > >> >> >> > to
    > >> >> >> > narrow it down to teh fact that we've got a preappend on the ID
    > >> >> >> > of
    > >> >> >> > the
    > >> >> >> > controls of "_ctl0" and as an underscore isn't a valid start
    > >> >> >> > character,
    > >> >> >> > firefox doesn't run the javascript (quite rightly).
    > >> >> >> > I'd prefer to alter this within the original code that creates
    > >> >> >> > the
    > >> >> >> > sub
    > >> >> >> > controls rather than hack it in the other project as it's to be
    > >> >> >> > part
    > >> >> >> > of
    > >> >> >> > a common library for use elsewhere.
    > >> >> >> >
    > >> >> >
    > >> >

    > >
    RVB, Sep 26, 2006
    #10
    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. David Whitney
    Replies:
    1
    Views:
    584
    Natty Gur
    Jul 21, 2003
  2. Henri
    Replies:
    2
    Views:
    12,055
    Henri
    May 18, 2004
  3. Kepler
    Replies:
    1
    Views:
    423
    Kepler
    Jul 7, 2004
  4. =?Utf-8?B?QXJuZQ==?=

    page.UniqueID

    =?Utf-8?B?QXJuZQ==?=, Dec 7, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    610
    =?Utf-8?B?QXJuZQ==?=
    Dec 7, 2004
  5. Ken Baltrinic

    UniqueID vs. ClientID Why are they Differenct?

    Ken Baltrinic, Mar 4, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    8,750
    Ken Baltrinic
    Mar 4, 2005
Loading...

Share This Page