Get values of dynamically created radio button control

K

Karthick Kumar

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
 
A

Alex

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top