Get values of dynamically created radio button control

Get values of dynamically created radio button control

Post by tvkarthic » Sat, 06 Nov 2004 20:07:10


Hi,

I have the following code which displays all the images from a
specific folder with a Radio button in it:

Dim objFile
i = 1
For Each objFile In objFolder.Files

If (i = 1) Then Response.Write("<TR>")

Response.Write("<TD align='center'>")
Response.Write("<IMG src='" & f_strCardPath & "\" &
objFile.Name & "' width='150px' height='150px'>")
Response.Write("<BR><INPUT type='radio' name='rdCardPics'
value='" & objFile.Name & "'")
Response.Write("</TD>")

If (i = 2) Then
Response.Write("</TR>")
i = 1
Else
i = i + 1
End If
Next

Now, the above with the other needed code is in a function (in
.aspx.vb
file) and I call it in the .aspx file as <%
DispImages(\imagefolderpath) %>

But once the user selects the image he wants, I want to pick up the
selected value of the radio button, how do I do that ?. Anybody got
any example on this ?.

Please help, thanks.

Regards,
Karthick
 
 
 

Get values of dynamically created radio button control

Post by Alex » Sun, 07 Nov 2004 03:08:40

The problem is that your inputs do not have ID's that are name friendly,
meaning, they are created dynamically, so their ID is not something easy to
determine at run time without knowing some data first. I would in your case,
place this information in a DataRepeater, and set a group for your radio
buttons. Give some common name to both the image and the radio button. I
might even use an asp:imagebutton instead of an html image control. If you
can send your viewed source from your browser, I can take a better look at
how the controls are rendered to the screen and perhaps add more. The part
that is tricky is when you click on an image, how can you tell which radio
button this corresponds. Send some html viewed source so we can look at it.

Alex