469,927 Members | 1,842 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

Get values of dynamically created radio button control

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
Nov 18 '05 #1
1 3066
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

"Karthick Kumar" <tv********@gmail.com> wrote in message
news:29**************************@posting.google.c om...
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

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mike P | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.