• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Quick ASP preference question

DJFuji

Diamond Member
Working on some mods for a legacy app that involves "classic" ASP 3.0. Now I really apprecate .NET's infrastructure.

Anyhow, while I was coding I started to wonder if other people code submit buttons differently. Whenever I have a page with multiple submit buttons, I name them differently and then do a

if request.form("submitbtn") <> "" then

line of code to tell which button was pressed. I got to thinking that maybe it would be easier if I named all the buttons the same and then just made the values different and queried the request.form("genericbuttonname") on what its value was. (kinda like when you have a check box column)

Do you guys do it like that or the way I do it? Is one method better than another or does it just come down to preference?
 
You can give each submit button a different value and then check to see which submit button was checked:

if request.form("submit1") <> "" then

elseif request.form("submit2") <> "" then

end if

That should work.
 
Originally posted by: SALvation
You can give each submit button a different value and then check to see which submit button was checked:

if request.form("submit1") <> "" then

elseif request.form("submit2") <> "" then

end if

That should work.

No. If you give them different values, then the value is different, not the key in request.form. If they all have the same name, you'd do request.form("name") and check the value.

To answer the question, I prefer the same name for submit generally. There are some instances where it doesn't work out well to do it though.
 
thanks torpid that's kinda what i was wondering. What situations have you run into where it doesnt work right?
 
Originally posted by: DJFuji
thanks torpid that's kinda what i was wondering. What situations have you run into where it doesnt work right?

Well, it still "works" but it doesn't always suit your needs. A submit button's text is the same as the value. So if you need two buttons called "Go" on the same form you will have to use a different technique to figure out which was clicked.
 
Back
Top