aspx placeholder question
Results 1 to 15 of 15

Thread: aspx placeholder question

  1. #1
    Registered User Fubarian's Avatar
    Join Date
    Dec 2000
    Location
    Columbus, Ohio
    Posts
    1,117

    aspx placeholder question

    ok, so I've wrote this slick little piece to dynamically add a list of clients to a page using a placeholder... num is the selecteditem.value from the client list (numbers 1 - 30) and then runs this fucntion...

    Code:
    'num given from client number postback
    function makeclientlist(num as integer)
    
    'clear the placeholder -- prohibits infinite clients
        placeholder.controls.clear()
    
    
        dim i as integer
    
    'for i to number of clients do this stuff
       for i = 1 to num
    
    'definte first label, Client1, client2, client3 ID
        dim Label = new Label()
        label.id = "Client" & i
        label.text = "Client : "
        placeholder.controls.add(label)
    
    'define textbox, clientbox1, clientbox2, etc
        dim Box = new textbox()
        box.ID = "clientbox" & i
        placeholder.controls.add(box)
    
        dim dept = new DropDownList()
        dept.ID = "clientdeptlist" & i
        dept.items.add("Public Safety")
        dept.items.add("Utilities")
        placeholder.controls.add(dept)
    
        dim div = new DropDownList()
        div.ID = "clientdivlist" & i
        div.items.add("police")
        div.items.add("fire")
        div.items.add("park")
        placeholder.controls.add(div)
    
        dim endlabel = new label()
        endlabel.id = "endlabel" & i
        endlabel.text = "<br>"
        placeholder.controls.add(endlabel)
    
       next i
    
    end function
    output works great, no problems -- what IS the issue is pulling that data people enter into that. So far, I've tried this...

    Code:
        'dim ctrl
    
        'for each ctrl in placeholder.controls
    
        '    select case ctrl.gettype().tostring()
    
        '         case "System.Web.UI.WebControls.Label"
        '         if not ctrl.text = "<br>"
        '            clientmessage &= ctrl.id & " " & ctrl.text & "<br>"
        '         end if
    
        '         case "System.Web.UI.WebControls.TextBox"
        '            clientmessage &= ctrl.text & "<br>"
    
        '         case "System.Web.UI.WebControls.DropDownList"
        '            clientmessage &= ctrl.selectedvalue & "<br>"
    
        '    end select
       ' next
    that didn't work, then I tried a for i = placeholder.controls.count - 1 loop, which failed as well. Anyone have an idea on how to grab the data the users input into boxes generated by a placeholder??

  2. #2
    Driver Terrier NooNoo's Avatar
    Join Date
    Dec 2000
    Location
    UK
    Posts
    31,824
    If I am reading this right... I think you need to examine the contents of textbox in which they typed... "clientbox" & i and not the controls.

  3. #3
    Registered User Fubarian's Avatar
    Join Date
    Dec 2000
    Location
    Columbus, Ohio
    Posts
    1,117
    so far I haven't found a way because technically the controls don't exist individually, only in the placeholder. In theory, ctrl.text should equal the control at that point (ie clientbox1, so clientbox1.text should be valid) but in doing so ...I think it errors out saying .text is not a member.

  4. #4
    Driver Terrier NooNoo's Avatar
    Join Date
    Dec 2000
    Location
    UK
    Posts
    31,824
    hmm so maybe you have to save the input text to a bunch of local variables? after all its the text they type in you are after, not the controls themselves...right?

  5. #5
    Registered User Fubarian's Avatar
    Join Date
    Dec 2000
    Location
    Columbus, Ohio
    Posts
    1,117
    sort of. I want what they enter in and select from the two dropdowns (box.text and list.selecteditem.value) -- in all other cases, its usually just as simple as that ...

    'add this to message
    message &= "Dept Selected : " & dropdownlist1.selecteditem.value & "<br>"

    but because its generated within the placeholder, its a control (placeholder is the parent control of the items generated). From my understanding, you have to 'contact' the controls within that parent. Thats the idea with the select statement because a label doesn't have a .selecteditem.value

    hehe see why this is fusterating as hell?

  6. #6
    Driver Terrier NooNoo's Avatar
    Join Date
    Dec 2000
    Location
    UK
    Posts
    31,824
    OK a little google I came up with this I think you need to iterate through the children IterateThroughChildren and cast the control type to it's proper type to access it.

  7. #7
    Registered User Fubarian's Avatar
    Join Date
    Dec 2000
    Location
    Columbus, Ohio
    Posts
    1,117
    Denied. It'll grab items pre-populated (I added box.text = "thisgoeshere" for fun) but not what the user enters/selects.

  8. #8
    Registered User Fubarian's Avatar
    Join Date
    Dec 2000
    Location
    Columbus, Ohio
    Posts
    1,117
    here's the "clientmessage" function for ref. reasons

    Code:
    function clientbuild() as string
    
    Dim ctrl
    
        for each ctrl in placeholder.Controls
    
            if ctrl.gettype.tostring() = "System.Web.UI.WebControls.TextBox"
                dim name as string = ctrl.ID
                dim textentered as string = ctype(ctrl, textbox).text
                clientmessage &= name & textentered & "<br>"
            end if
        next
    
        return clientmessage
    
    end function

  9. #9
    Driver Terrier NooNoo's Avatar
    Join Date
    Dec 2000
    Location
    UK
    Posts
    31,824
    more digging...

    When the ASP.NET Web page is posted back in the load postback data stage, the Page class sees that one of the posted back form fields corresponds to the IPostBackDataHandler interface. There is such a control in the hierarchy, so the TextBox's LoadPostData() method is invoked, passing in the value the user entered into the TextBox ("Hello, World!"). The TextBox's LoadPostData() method simply assigns this passed in value to its Text property.

  10. #10
    Registered User Fubarian's Avatar
    Join Date
    Dec 2000
    Location
    Columbus, Ohio
    Posts
    1,117
    page still doesn't agree. I'm not sure what the next step is...

    Interesting. I created a button ...made a click event that is, well, empty and every time I click the 'dummy button', it clears everything out of that control, but not the other controls (I have one for judges, attorneys, etc that are drop downs and a few other text boxes) -- those do not clear. I bet that has something to do with it.

  11. #11
    Driver Terrier NooNoo's Avatar
    Join Date
    Dec 2000
    Location
    UK
    Posts
    31,824
    ok.. so I would look at the casting to type... maybe it means not just to text box but to the individual text box object judges.textbox?

  12. #12
    Registered User Fubarian's Avatar
    Join Date
    Dec 2000
    Location
    Columbus, Ohio
    Posts
    1,117
    I got it! I GOT IT!!! ::happy dance::

    I was wondering what the problem was with the clearing every time there was a (keyword coming..wait for it ..............................) postback.

    All I had to do was move my function makeclientlist(clientlist.selecteditem.value) to the PageLoad area, leave the "postback" enabled on the dropdown clientlist and bingo, works like a charm.

    Since the value is taken during a postback, it passes it to pageload where it then calls the makeclientlist(value) and runs the fucntion. Freakin sweet, I knew it was an order op problem, it had to be.

    So in closing, I'm just an idiot Thanks for the help NooNoo.

  13. #13
    Driver Terrier NooNoo's Avatar
    Join Date
    Dec 2000
    Location
    UK
    Posts
    31,824
    Glad to be a sounding board... btw is that the same happy dance that snoopy does?

  14. #14
    Registered User Fubarian's Avatar
    Join Date
    Dec 2000
    Location
    Columbus, Ohio
    Posts
    1,117
    you've seen the bananna dance guy? ...that'd be the happy dance right now ...only in a chair; An uncomfy chair not built for anyone over 6' 3 (I'm 6'8)

  15. #15
    Driver Terrier NooNoo's Avatar
    Join Date
    Dec 2000
    Location
    UK
    Posts
    31,824
    A tall story no doubt

Similar Threads

  1. [RESOLVED] 70-240: LETS DO THIS!!
    By 70-240 in forum Certification
    Replies: 14
    Last Post: February 20th, 2012, 03:35 AM
  2. [RESOLVED] question about FIC SD11
    By StyxenStones in forum BIOS/Motherboard Drivers
    Replies: 5
    Last Post: December 1st, 2004, 08:13 PM
  3. A question for system builders.
    By sardo_numspa in forum Tech-To-Tech
    Replies: 17
    Last Post: June 17th, 2002, 05:44 AM
  4. Mobo question
    By DSTech in forum Tech-To-Tech
    Replies: 0
    Last Post: December 6th, 2001, 01:35 AM
  5. As promised, the BE6-II question
    By pcshark in forum Tech-To-Tech
    Replies: 3
    Last Post: July 17th, 2000, 01:48 PM

Bookmarks

Posting Permissions

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