Approaches to Web Development for Bioinformatics
Working with Forms
Working with forms in ASP is similar to JSP and PHP. Here is an example that uses the RNA validator
class RNAValidator.cs from the section
Types in C#.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
</head>
<body>
<%
String rna= Request.QueryString["rna"];
if (rna == null)
{
%>
<form id="form1" action="inputform.aspx">
<div>
<p>Please enter an RNA string.</p>
RNA: <input name="rna" type="text"><br/><br/>
<input type="submit" name="Lookup" value="Submit">
</div>
</form>
<%
}
else
{
%>
<p>Validation result: The input RNA string </p>
<%=HttpUtility.HtmlEncode(rna)%><br/>
<%
Validator validator = new RNAValidator();
if (validator.isValid(rna))
{
%>
<p>is valid.</p>
<%
}
else
{
%>
<p>is not valid.</p>
<%
}
}
%>
<a href="inputform.aspx">Back</a>
</body>
</html>
The page first checks to see if the request parameter named "rna" has been sent. If not if
prompts the user to enter an RNA string in the textfield. Once the user submits the RNA string
by clicking the submit button the page validates the result. The input data is repeated back
to the user, the string is validated, and then a message is given to the user. The screen
shots below show the result for an RNA string of auggcacaggca.
ASP.NET Example Form Input
ASP.NET Example Form Data Collection and Validation
There are no user comments.
Please send ideas and opinions by email at alexamies@gmail.com.
© 2006-2007 Alex Amies