problem with INamingContainer

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Re: problem with INamingContainer

    Ya sure,

    this is the code for 3 text boxes generated:


    </div><div id="Panel1" style="height:212px;width:380px;Z-INDEX: 102; LEFT:
    439px; POSITION: absolute; TOP: 386px">
    Panel<span id="Sat"><table id="Sat_tblEntry" border="0">
    <tr id="Sat_ThisRow1532">
    <td></td><td></td><td><input name="Sat:ThisRow1532:TXT1532" type="text"
    id="Sat_ThisRow1532_TXT1532" /></td><td></td>
    </tr><tr id="Sat_ThisRow2663">
    <td></td><td></td><td><input name="Sat:ThisRow2663:TXT2663" type="text"
    id="Sat_ThisRow2663_TXT2663" /></td><td></td>
    </tr><tr id="Sat_ThisRow3726">
    <td></td><td></td><td><input name="Sat:ThisRow3726:TXT3726" type="text"
    id="Sat_ThisRow3726_TXT3726" /></td><td><span id="Sat_ThisRow3726__ctl0"
    controltovalidate="Sat_ThisRow3726_TXT3726" errormessage="test me"
    display="Dynamic"
    evaluationfunction="RegularExpressionValidatorEval uateIsValid"
    validationexpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
    style="color:Red;display:none;">test me</span></td>
    </tr>
    </table></span>

    Just for your info:

    I even tried to use page.findcontrol and set the uniqueid, clientid and id
    properties individually for the control, but it doesn't works!!!

    Also, i tried to set Sat:ThisRow1532:TXT1532
    Also, i tired to set ThisRow1532:TXT1532
    Also, i tried to set Sat_ThisRow1532_TXT1532

    But, all in the above cases it fails and says control not found.
    JUST TO REMIND AGAIN WHEN I AM RENDERID "TXT3726" AT THAT TIME I M TRYING
    TO VALIDATE "TXT1532",
    REASON: I WANT TO USE COMPAREVALIDATOR ON IT.

    Waiting for reply,

    thanks in advance,
    satinder


    "William F. Robertson, Jr." <wfrobertson@kpmg.com> wrote in message
    news:Oiter8dODHA.1748@TK2MSFTNGP11.phx.gbl...
    > So you are saying you are passing aobjViewRowProp because you were using
    it
    > in the past, but now you are trying to use the TestClass mobjViewRow?
    >
    > Try also changing the ControlToValidate to x.ID instead of hard coding it.
    > I know on my composite controls, (that implement INamingContainer) I have
    to
    > reference the exact ID of it. I couldn't just type it in, because of the
    > UniqueID that gets generated for INamingContainer.
    >
    > Would you post a sample of what your view source from IE looks like? I
    > think I just about have something figured out for you, I just need a
    little
    > bit more.
    >
    > bill
    >
    > "SatinderGT" <satinder@thegt.com> wrote in message
    > news:#fWMdEVODHA.2096@TK2MSFTNGP12.phx.gbl...
    > > Hi William,
    > >
    > > aobjViewRowProp is declared as type TableRow and this row is used to add
    > the
    > > cotnrols.
    > > If i declare it as tablerow and do what is rquired, then it works fine.
    > But,
    > > if i declare aobjViewRowProp as TestClass (that implements
    > > INamingContainer), then it says Control TXT1532 not found. If i do not
    > > implement INamingContainer it works fine (but implementation of
    > > INamingContainer is required).
    > > Note that if i change the condition to :
    > >
    > > > > If x.ID = "TXT1532" Then
    > > > > Dim rfv As New RegularExpressionValidator()
    > > > >
    > > > > With rfv
    > > > > .ControlToValidate = "TXT1532"
    > > > > .ValidationExpression =
    > > > > "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
    > > > > .ErrorMessage = "test me"
    > > > > .Display = ValidatorDisplay.Dynamic
    > > > > End With
    > > > > tdDescription.Controls.Add(rfv)
    > > > > End If
    > >
    > > THE ABOVE CODE WORKS FINE !!! NOTE HERE TXT1532 IS CHECKED AND ADDED.
    > > IN PREVIOUS CODE TXT3726 WAS CHECKED AND TXT1532 WAS ADDED.
    > >
    > > I saw the source code carefully that the control has generated after
    > > INamingContainer, but specfying the ids generated by INamingContainer
    > > doesn't helps.
    > > I need this as i want to add CompareValidator, i want to check the value
    > of
    > > one control with another. All happens Dynamically.
    > >
    > >
    > > Please help.
    > >
    > > thanks
    > > sat
    > >
    > >
    > > "William F. Robertson, Jr." <wfrobertson@kpmg.com> wrote in message
    > > news:uS4juQ0NDHA.2788@TK2MSFTNGP10.phx.gbl...
    > > > This probably won't solve your problem, but these are just some
    > questions.
    > > >
    > > > Why are you passing in aobjViewRowProp to AddControlToTable(...) when
    > you
    > > > aren't using it inside your method?
    > > >
    > > > Look at the source code generated using the INamingContainer. See how
    > it
    > > is
    > > > naming your control. I can't think of how it would be now, but look
    at
    > it
    > > > and make sure the ControlToValidate property rendered are the same as
    > the
    > > > clientID of the control you are wishing to develop.
    > > >
    > > > bill
    > > >
    > > >
    > > >
    > > > "SatinderGT" <satinder@thegt.com> wrote in message
    > > > news:u92RWqxNDHA.2064@TK2MSFTNGP10.phx.gbl...
    > > > > Dear Group,
    > > > >
    > > > > A problem with INamingContainer reflecting Validator control:
    > > > >
    > > > > Exact Implementation:
    > > > >
    > > > > I have a class that Inherits TableRow and implements
    INamingContainer
    > > > >
    > > > > Public Class TestClass
    > > > > Inherits TableRow
    > > > > Implements INamingContainer
    > > > >
    > > > > End Class
    > > > >
    > > > >
    > > > > In the CreateChildControls i have following Code:
    > > > >
    > > > > tblMain = New Table()
    > > > > Me.Controls.Add(tblMain)
    > > > > Call AddEntryControls()
    > > > > AddEntryContorls Method has this code:
    > > > >
    > > > > Private Sub AddEntryControls()
    > > > > tblMain.ID = "tblEntry"
    > > > > Dim objViewRowProp As New TableRow()
    > > > >
    > > > > AddControlToTable(objViewRowProp, 1532)
    > > > > AddControlToTable(objViewRowProp, 2663)
    > > > > AddControlToTable(objViewRowProp, 3726)
    > > > > End Sub
    > > > >
    > > > > And AddControlToTable does this:
    > > > >
    > > > >
    > > > > Private Sub AddControlToTable(ByVal aobjViewRowProp As TableRow,
    ByVal
    > > > > aintFieldRID As Int64, Optional ByVal astrCount As String = "",
    > Optional
    > > > > ByVal ablnAddValidator As Boolean = True)
    > > > > Dim mobjViewRow As New TestClass()
    > > > >
    > > > > Dim tdCaption As New TableCell()
    > > > > Dim tdMandatory As New TableCell()
    > > > > Dim tdControl As New TableCell()
    > > > > Dim tdDescription As New TableCell()
    > > > >
    > > > > Dim x As New TextBox()
    > > > >
    > > > > x.ID = "TXT" & aintFieldRID
    > > > >
    > > > > If x.ID = "TXT3726" Then
    > > > > Dim rfv As New RegularExpressionValidator()
    > > > >
    > > > > With rfv
    > > > > .ControlToValidate = "TXT1532"
    > > > > .ValidationExpression =
    > > > > "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
    > > > > .ErrorMessage = "test me"
    > > > > .Display = ValidatorDisplay.Dynamic
    > > > > End With
    > > > > tdDescription.Controls.Add(rfv)
    > > > > End If
    > > > >
    > > > > tdControl.Controls.Add(x)
    > > > >
    > > > > mobjViewRow.Cells.Add(tdCaption)
    > > > > mobjViewRow.Cells.Add(tdMandatory)
    > > > > mobjViewRow.Cells.Add(tdControl)
    > > > > mobjViewRow.Cells.Add(tdDescription)
    > > > >
    > > > > tblMain.Rows.Add(mobjViewRow)
    > > > >
    > > > > End Sub
    > > > >
    > > > > NOTICE, WHEN WE ARE ADDING "TXT3726" WE VALIDATE "TXT1532".
    > > > >
    > > > > Now, the problem is if i try to run this code it says control
    TXT1532
    > > not
    > > > > found. And if i remove implementation of INamingContainer it works
    > fine
    > > > !!!
    > > > >
    > > > > What could be the reason ???
    > > > >
    > > > > Any help would be highly appreciated.
    > > > >
    > > > >
    > > > >
    > > > > Thanks in advance,
    > > > >
    > > > > Satinder Singh
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    SatinderGT Guest

  2. Similar Questions and Discussions

    1. contribute problem - access denied file may not existpermission problem
      Recieving the following error message - "access denied file may not exist , or there could be a permission problem" this happened this morning ,...
    2. INamingContainer has change my controls event order.....
      Hi All, I have built a composite user web control and I've NOT implemented INamingContainer. It does implement IPostBackDataHandler to retrieve...
    3. Uploading problem = weird warning (was: access denied problem.....)
      Hi, I had a problem where my upload form was not working on our production server but was working on two other servers, after checking the...
    4. #21611 [Opn]: Problem with version_compare() (Was: Problem with pear cli and release numbers)
      ID: 21611 Updated by: et@php.net -Summary: Problem with pear cli and release numbers Reported By: jan at horde...
    5. Problem with Apache Web Server config file and PHP (please give advice on what problem may be me)
      HI: Can anyone refer me to someone that can help with the problem below. I installed Apache Web Server on my laptop which has Windows XP. I...
  3. #2

    Default Re: problem with INamingContainer

    Okay, I have been researching this for a while and here is what I came up
    with. The short answer is to NOT use INamingContainer. However, not using
    it, you will have to come up with your own naming scheme to guarantee there
    are not any duplicate names.

    Using INamingContainer will guarantee all controls added with have a unique
    name. What is happening is the naming interface is giving the textbox
    control a unique name: sat_thisrow1532_txt1532. When the sat_thisrow3726 is
    rendering the validator on it is to txt1532, but it is being appended with
    sat_thisrow3726_txt1532.

    I looked and could not find a way to override the interface functionality
    for a validate control id.

    Points.

    1) are you sure it is required to implement the INamingContainer? Could you
    just implement your own naming scheme when you added the controls? ie
    append the row name and id before the type. Kinda mimick the
    INamingContainer functionality?

    2) You could write a custom control for that cell, that inside the cell, you
    write out the validator by hand. It is kinda a hack that way, but you know
    what the html is supposed to look like, just look into registering a
    validator with the page and go from there.

    Sorry I couldn't be of any more assistance.

    bill

    "SatinderGT" <satinder@thegt.com> wrote in message
    news:uP3TdzvODHA.3192@TK2MSFTNGP10.phx.gbl...
    > Ya sure,
    >
    > this is the code for 3 text boxes generated:
    >
    >
    > </div><div id="Panel1" style="height:212px;width:380px;Z-INDEX: 102; LEFT:
    > 439px; POSITION: absolute; TOP: 386px">
    > Panel<span id="Sat"><table id="Sat_tblEntry" border="0">
    > <tr id="Sat_ThisRow1532">
    > <td></td><td></td><td><input name="Sat:ThisRow1532:TXT1532" type="text"
    > id="Sat_ThisRow1532_TXT1532" /></td><td></td>
    > </tr><tr id="Sat_ThisRow2663">
    > <td></td><td></td><td><input name="Sat:ThisRow2663:TXT2663" type="text"
    > id="Sat_ThisRow2663_TXT2663" /></td><td></td>
    > </tr><tr id="Sat_ThisRow3726">
    > <td></td><td></td><td><input name="Sat:ThisRow3726:TXT3726" type="text"
    > id="Sat_ThisRow3726_TXT3726" /></td><td><span id="Sat_ThisRow3726__ctl0"
    > controltovalidate="Sat_ThisRow3726_TXT3726" errormessage="test me"
    > display="Dynamic"
    > evaluationfunction="RegularExpressionValidatorEval uateIsValid"
    > validationexpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
    > style="color:Red;display:none;">test me</span></td>
    > </tr>
    > </table></span>
    >
    > Just for your info:
    >
    > I even tried to use page.findcontrol and set the uniqueid, clientid and id
    > properties individually for the control, but it doesn't works!!!
    >
    > Also, i tried to set Sat:ThisRow1532:TXT1532
    > Also, i tired to set ThisRow1532:TXT1532
    > Also, i tried to set Sat_ThisRow1532_TXT1532
    >
    > But, all in the above cases it fails and says control not found.
    > JUST TO REMIND AGAIN WHEN I AM RENDERID "TXT3726" AT THAT TIME I M
    TRYING
    > TO VALIDATE "TXT1532",
    > REASON: I WANT TO USE COMPAREVALIDATOR ON IT.
    >
    > Waiting for reply,
    >
    > thanks in advance,
    > satinder
    >
    >
    > "William F. Robertson, Jr." <wfrobertson@kpmg.com> wrote in message
    > news:Oiter8dODHA.1748@TK2MSFTNGP11.phx.gbl...
    > > So you are saying you are passing aobjViewRowProp because you were using
    > it
    > > in the past, but now you are trying to use the TestClass mobjViewRow?
    > >
    > > Try also changing the ControlToValidate to x.ID instead of hard coding
    it.
    > > I know on my composite controls, (that implement INamingContainer) I
    have
    > to
    > > reference the exact ID of it. I couldn't just type it in, because of
    the
    > > UniqueID that gets generated for INamingContainer.
    > >
    > > Would you post a sample of what your view source from IE looks like? I
    > > think I just about have something figured out for you, I just need a
    > little
    > > bit more.
    > >
    > > bill
    > >
    > > "SatinderGT" <satinder@thegt.com> wrote in message
    > > news:#fWMdEVODHA.2096@TK2MSFTNGP12.phx.gbl...
    > > > Hi William,
    > > >
    > > > aobjViewRowProp is declared as type TableRow and this row is used to
    add
    > > the
    > > > cotnrols.
    > > > If i declare it as tablerow and do what is rquired, then it works
    fine.
    > > But,
    > > > if i declare aobjViewRowProp as TestClass (that implements
    > > > INamingContainer), then it says Control TXT1532 not found. If i do not
    > > > implement INamingContainer it works fine (but implementation of
    > > > INamingContainer is required).
    > > > Note that if i change the condition to :
    > > >
    > > > > > If x.ID = "TXT1532" Then
    > > > > > Dim rfv As New RegularExpressionValidator()
    > > > > >
    > > > > > With rfv
    > > > > > .ControlToValidate = "TXT1532"
    > > > > > .ValidationExpression =
    > > > > > "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
    > > > > > .ErrorMessage = "test me"
    > > > > > .Display = ValidatorDisplay.Dynamic
    > > > > > End With
    > > > > > tdDescription.Controls.Add(rfv)
    > > > > > End If
    > > >
    > > > THE ABOVE CODE WORKS FINE !!! NOTE HERE TXT1532 IS CHECKED AND ADDED.
    > > > IN PREVIOUS CODE TXT3726 WAS CHECKED AND TXT1532 WAS ADDED.
    > > >
    > > > I saw the source code carefully that the control has generated after
    > > > INamingContainer, but specfying the ids generated by INamingContainer
    > > > doesn't helps.
    > > > I need this as i want to add CompareValidator, i want to check the
    value
    > > of
    > > > one control with another. All happens Dynamically.
    > > >
    > > >
    > > > Please help.
    > > >
    > > > thanks
    > > > sat
    > > >
    > > >
    > > > "William F. Robertson, Jr." <wfrobertson@kpmg.com> wrote in message
    > > > news:uS4juQ0NDHA.2788@TK2MSFTNGP10.phx.gbl...
    > > > > This probably won't solve your problem, but these are just some
    > > questions.
    > > > >
    > > > > Why are you passing in aobjViewRowProp to AddControlToTable(...)
    when
    > > you
    > > > > aren't using it inside your method?
    > > > >
    > > > > Look at the source code generated using the INamingContainer. See
    how
    > > it
    > > > is
    > > > > naming your control. I can't think of how it would be now, but look
    > at
    > > it
    > > > > and make sure the ControlToValidate property rendered are the same
    as
    > > the
    > > > > clientID of the control you are wishing to develop.
    > > > >
    > > > > bill
    > > > >
    > > > >
    > > > >
    > > > > "SatinderGT" <satinder@thegt.com> wrote in message
    > > > > news:u92RWqxNDHA.2064@TK2MSFTNGP10.phx.gbl...
    > > > > > Dear Group,
    > > > > >
    > > > > > A problem with INamingContainer reflecting Validator control:
    > > > > >
    > > > > > Exact Implementation:
    > > > > >
    > > > > > I have a class that Inherits TableRow and implements
    > INamingContainer
    > > > > >
    > > > > > Public Class TestClass
    > > > > > Inherits TableRow
    > > > > > Implements INamingContainer
    > > > > >
    > > > > > End Class
    > > > > >
    > > > > >
    > > > > > In the CreateChildControls i have following Code:
    > > > > >
    > > > > > tblMain = New Table()
    > > > > > Me.Controls.Add(tblMain)
    > > > > > Call AddEntryControls()
    > > > > > AddEntryContorls Method has this code:
    > > > > >
    > > > > > Private Sub AddEntryControls()
    > > > > > tblMain.ID = "tblEntry"
    > > > > > Dim objViewRowProp As New TableRow()
    > > > > >
    > > > > > AddControlToTable(objViewRowProp, 1532)
    > > > > > AddControlToTable(objViewRowProp, 2663)
    > > > > > AddControlToTable(objViewRowProp, 3726)
    > > > > > End Sub
    > > > > >
    > > > > > And AddControlToTable does this:
    > > > > >
    > > > > >
    > > > > > Private Sub AddControlToTable(ByVal aobjViewRowProp As TableRow,
    > ByVal
    > > > > > aintFieldRID As Int64, Optional ByVal astrCount As String = "",
    > > Optional
    > > > > > ByVal ablnAddValidator As Boolean = True)
    > > > > > Dim mobjViewRow As New TestClass()
    > > > > >
    > > > > > Dim tdCaption As New TableCell()
    > > > > > Dim tdMandatory As New TableCell()
    > > > > > Dim tdControl As New TableCell()
    > > > > > Dim tdDescription As New TableCell()
    > > > > >
    > > > > > Dim x As New TextBox()
    > > > > >
    > > > > > x.ID = "TXT" & aintFieldRID
    > > > > >
    > > > > > If x.ID = "TXT3726" Then
    > > > > > Dim rfv As New RegularExpressionValidator()
    > > > > >
    > > > > > With rfv
    > > > > > .ControlToValidate = "TXT1532"
    > > > > > .ValidationExpression =
    > > > > > "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
    > > > > > .ErrorMessage = "test me"
    > > > > > .Display = ValidatorDisplay.Dynamic
    > > > > > End With
    > > > > > tdDescription.Controls.Add(rfv)
    > > > > > End If
    > > > > >
    > > > > > tdControl.Controls.Add(x)
    > > > > >
    > > > > > mobjViewRow.Cells.Add(tdCaption)
    > > > > > mobjViewRow.Cells.Add(tdMandatory)
    > > > > > mobjViewRow.Cells.Add(tdControl)
    > > > > > mobjViewRow.Cells.Add(tdDescription)
    > > > > >
    > > > > > tblMain.Rows.Add(mobjViewRow)
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > > > NOTICE, WHEN WE ARE ADDING "TXT3726" WE VALIDATE "TXT1532".
    > > > > >
    > > > > > Now, the problem is if i try to run this code it says control
    > TXT1532
    > > > not
    > > > > > found. And if i remove implementation of INamingContainer it works
    > > fine
    > > > > !!!
    > > > > >
    > > > > > What could be the reason ???
    > > > > >
    > > > > > Any help would be highly appreciated.
    > > > > >
    > > > > >
    > > > > >
    > > > > > Thanks in advance,
    > > > > >
    > > > > > Satinder Singh
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    William F. Robertson, Jr. Guest

  4. #3

    Default Problem with INamingContainer

    I created a composite control which works just fine. I want to be able to
    set the focus to one of its contained controls (a textbox) but this is
    giving me a javascript error. The problem is that the ClientID property of
    the contained textbox is not giving me the correct value. When I debug the
    application the contained textbox's ClientID is "myControl__ctl1", but when
    I look at the generated HTML the input tag looks like this: <input
    name="myControl:_ctl1" ... />

    How did the first "_" turn into ":" and how do I fix this?

    --
    Sergio Florez M.
    Medellín, Colombia


    Sergio FLorez M. Guest

  5. #4

    Default Re: Problem with INamingContainer

    You don't, really. The ID will be NamingContainerID_ChildID, and the
    name will be NamingContainerID:ChildID. That's just the way it works.
    If you're using Javascript, you could do
    document.getElementById(ClientID).focus()

    Otherwise, you're going to have to override Render and manually set the
    name equal to the id. That's a pain, and unnecessary.

    Lisa


    Sergio FLorez M. wrote:
    > I created a composite control which works just fine. I want to be able to
    > set the focus to one of its contained controls (a textbox) but this is
    > giving me a javascript error. The problem is that the ClientID property of
    > the contained textbox is not giving me the correct value. When I debug the
    > application the contained textbox's ClientID is "myControl__ctl1", but when
    > I look at the generated HTML the input tag looks like this: <input
    > name="myControl:_ctl1" ... />
    >
    > How did the first "_" turn into ":" and how do I fix this?
    >
    > --
    > Sergio Florez M.
    > Medellín, Colombia
    lisa@starways.net Guest

  6. #5

    Default Re: Problem with INamingContainer

    Actually, that's exactly what I was using -
    document.getElementById(ClientID).focus()

    The solution is really simple. Instead of ClientID I have to use UniqueID.

    --
    Sergio Florez M.
    Medellín, Colombia

    <lisa@starways.net> wrote in message
    news:1119281080.663361.21240@g49g2000cwa.googlegro ups.com...
    You don't, really. The ID will be NamingContainerID_ChildID, and the
    name will be NamingContainerID:ChildID. That's just the way it works.
    If you're using Javascript, you could do
    document.getElementById(ClientID).focus()

    Otherwise, you're going to have to override Render and manually set the
    name equal to the id. That's a pain, and unnecessary.

    Lisa


    Sergio FLorez M. wrote:
    > I created a composite control which works just fine. I want to be able to
    > set the focus to one of its contained controls (a textbox) but this is
    > giving me a javascript error. The problem is that the ClientID property of
    > the contained textbox is not giving me the correct value. When I debug the
    > application the contained textbox's ClientID is "myControl__ctl1", but
    when
    > I look at the generated HTML the input tag looks like this: <input
    > name="myControl:_ctl1" ... />
    >
    > How did the first "_" turn into ":" and how do I fix this?
    >
    > --
    > Sergio Florez M.
    > Medellín, Colombia

    Sergio FLorez M. Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139