Wednesday, November 14, 2007

How to handle parsing variable in ASP

Dealing with variables in web development always painful, since there will be lots of variable to be transferred and we have to transfer them to the new variable on the next page. But how if it's transferring variable to the same page? We have to smartly transfered variable to the same variable.

It pain you more in ASP when you really have to do that for say . . . 10 variables? In PHP you just need to set GlobalVariable option on. But in ASP you need to trick it.

I found something useful here : http://www.aspwebpro.com/tutorials/asp/newwaytohandlevar.asp

The the line of code you can use :
<%
For Each Field in Request.Form
TheString = Field & "= Request.Form(""" & Field & """)"
Execute(TheString)
Next
%>

After using it, just use the variables, as usual, you already skip the variable handling part.

No comments: