asp classic - How to check if a POST submitted field exists in VBScript? -


after form submitted, how 1 check server-side if particular field exists? example:

if [exists] request("fieldname")     ... end if 

check if it's not empty. there few different ways, 1 i've seen more used along lines of:

if request("fieldname") <> ""  'etc. end if 

i explicitly check form , querystring collections variation of 1 of code below if may getting variable 1 or other depending on context:

select case true     case request.form("fieldname") <> ""         'run if form isn't empty     case request.querystring("fieldname") <> ""         'run if querystring isn't empty     case else         'set predefined default if they're both empty end select 

or nested if ... then:

if request.form("fieldname") <> ""     'run if form isn't empty elseif request.querystring("fieldname") <> ""     'run if querystring isn't empty else     'set predefined default if they're both empty end if 

if know collection it's coming from, i'll check collection specifically. reason want make sure pulling expect expect come from. don't want overriding form value sending in querystring when i'm not expecting it.

from msdn:

if specified variable not in 1 of preceding 5 collections, request object returns empty.

all variables can accessed directly calling request(variable) without collection name. in case, web server searches collections in following order:

  • querystring
  • form
  • cookies
  • clientcertificate
  • servervariables

if variable same name exists in more 1 collection, request object returns first instance object encounters.

it recommended when referring members of collection full name used. example, rather request.("auth_user") use request.servervariables("auth_user"). allows server locate item more quickly.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -