
| 4.14 How do I pass a variable from WML to ASP? |
|
Let's say you have an ASP called "myasp.asp", and you have a WML variable called "wmlvar". When requested as "myasp.asp?wmlvar=something", you can grab the contents of the variable like this:
dim aspvar
aspvar = Request.QueryString("wmlvar")
The ASP variable "aspvar" will now contain the string "something". To make things easier, the ASP variable can of course have the same name as the WML variable.
Here is a sample showing different ways of passing variables
<%Response.ContentType = "text/vnd.wap.wml"%>
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<!-- VarTest.asp a code sample for Thewirelessfaq.com by Ed Alkema -->
<wml>
<%
dim i
dim z
dim NrThingy
dim Action
NrThingy = Request("NrThingy")
i = int(Request("i"))
Action = Request("Action")
z = Request.Querystring("z")
%>
<card id="foobar" title="Foobar" newcontext="true">
<p>z = <%=z%></p>
<p>i = <%=i%></p>
<p>NrThingy = <%=NrThingy%></p>
<p>Action = <%=Action%></p>
<p>Enter i <input name="i" type="text" maxlength="3" format="*N" /></p>
<p>
Choose nr Thingy
<select name="NrThingy" ivalue="<%=NrThingy%>">
<option value="1">1 Thingy</option>
<option value="2">2 Thingy</option>
<option value="3">3 Thingy</option>
</select>
</p>
<p>
<anchor title="Show">Show Thingy
<go href="vartest.asp?z=<%=i + 1%>" method="post">
<postfield name="i" value="$(i)" />
<postfield name="NrThingy" value="$(NrThingy)" />
<postfield name="Action" value="Hidden" />
</go>
</anchor>
</p>
</card>
</wml>
|
| Related information |
|
Chapter 8 in "Professional WAP" from Wrox |
| [ Main ] [ 04 - Serving WML contents ] |
| © 2001, 2002, 2003, 2004 This document is the collective property of the WMLProgramming and OUI-support mailing lists. |