|
-
September 6th, 2005, 03:34 PM
#1
Registered User
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??
-
September 7th, 2005, 05:15 AM
#2
Driver Terrier
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.
-
September 7th, 2005, 07:46 AM
#3
Registered User
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.
-
September 7th, 2005, 07:49 AM
#4
Driver Terrier
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?
-
September 7th, 2005, 09:54 AM
#5
Registered User
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?
-
September 7th, 2005, 10:40 AM
#6
Driver Terrier
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.
-
September 7th, 2005, 03:08 PM
#7
Registered User
Denied. It'll grab items pre-populated (I added box.text = "thisgoeshere" for fun) but not what the user enters/selects.
-
September 7th, 2005, 03:10 PM
#8
Registered User
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
-
September 7th, 2005, 04:19 PM
#9
Driver Terrier
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.
-
September 8th, 2005, 08:18 AM
#10
Registered User
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.
-
September 8th, 2005, 08:39 AM
#11
Driver Terrier
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?
-
September 8th, 2005, 09:10 AM
#12
Registered User
-
September 8th, 2005, 09:57 AM
#13
Driver Terrier
Glad to be a sounding board... btw is that the same happy dance that snoopy does?
-
September 8th, 2005, 10:12 AM
#14
Registered User
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)
-
September 8th, 2005, 12:37 PM
#15
Driver Terrier
A tall story no doubt
Similar Threads
-
By 70-240 in forum Certification
Replies: 14
Last Post: February 20th, 2012, 03:35 AM
-
By StyxenStones in forum BIOS/Motherboard Drivers
Replies: 5
Last Post: December 1st, 2004, 08:13 PM
-
By sardo_numspa in forum Tech-To-Tech
Replies: 17
Last Post: June 17th, 2002, 05:44 AM
-
By DSTech in forum Tech-To-Tech
Replies: 0
Last Post: December 6th, 2001, 01:35 AM
-
By pcshark in forum Tech-To-Tech
Replies: 3
Last Post: July 17th, 2000, 01:48 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|
Bookmarks