[thelist] Need name for use in Dyanically generated field name in ASP

Michele Foster foster.michele at gmail.com
Tue Feb 26 12:49:24 CST 2008

On 26/02/2008, Volkan Özçelik <volkan.ozcelik at gmail.com> wrote:
> Hi Michelle
> On Tue, Feb 26, 2008 at 6:45 PM, Michele Foster <foster.michele at gmail.com>
> wrote:
> >
> > However, for the dynamically generated fields, I can't seem to get ASP
> to
> > let me use the field name dynamically in an If statement so that I can
> > indicate if the field was checked or not. i.e.
> When the user agent submits the form the server received **only** the
> selected/checked input field values.
> For instance, for the form:
> ....

if g1_r2 radiobutton is checked the Request.Form collection will not have
> g1_r1
> similarly if g2_r2 is checked, the Request.Form collection will not have
> g2_r1
> thus in the above scenario,
> Request.Form["group1"] will return "radio1" and
> Request.Form["group2"] will (again) return "radio1" (the syntax is C#
> ASP.net, but it's quite similar in classic ASP)
> Which means that the second options (radio2) in each radio button group is
> not checked.
> ...
> In short anything you did not receive in the Request collection, and hence
> you cannot iterate, is unchecked.

Hi Volkan,

Thanks for the response.  However, that is not my problem.  I am already
able to get the values passed for the form fields.  The problem is that I
need to know what the form field name was so that when the page is
resubmitted, and there is an error, so the form redisplays, I want to
prefill the checks or radio options the user already selected.  The
difficulty is that I can't seem to write a dynamic IF statement in ASP to be
able to know which value was selected in the form field the first time it
was submitted.


<input type="checkbox" name="MyField-1" id="MyField-1" value="1" <% If
MyField-1 =1 then response.write "checked=""checked"" %> End If %> />

Where MyField-1 is dynamically built based on what's in the database.  If's
the If MyField-1  that I can't seem to get.  :(

Hope that's more clear.  Thanks again,

> Michele Foster
> Work - http://wizardev.ca/
> Play - http://mishka.ca/
> Fun - http://isitbeertimeyet.ca/

More information about the thelist mailing list