|
<%@ Page language="c#" Codebehind="WebParameterDemo.aspx.cs" AutoEventWireup="false" Inherits="WebControlTestWeb.WebParameterDemo" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>BoundParameterDemo</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="BoundParameterDemo" method="get" runat="server">
<H1>QueryString parameter binding demo</H1>
<P>Using the WebParameter attribute, the <STRONG>FirstName</STRONG> and <STRONG>CustomerID</STRONG>
fields in the underlying page class are 'bound' to <STRONG>txtFirstName</STRONG>
and <STRONG>txtCustomerID</STRONG> in the querystring. Additionally the
property <STRONG>LastName</STRONG> is bound to <STRONG>txtLast_Name</STRONG> in
the querystring.</P>
<P>In Page_Load the fields/properties are loaded from the querystring,
and the two fields values and the property value are
assigned to the controls.
</P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="300" border="1">
<TR>
<TD>First Name</TD>
<TD>
<INPUT type="text" runat="server" id="txtFirstName"></TD>
</TR>
<TR>
<TD>Last Name</TD>
<TD>
<INPUT id="txtLastName" type="text" runat="server"></TD>
</TR>
<TR>
<TD>Customer ID</TD>
<TD>
<INPUT id="txtCustomerID" type="text" runat="server"></TD>
</TR>
<TR>
<TD></TD>
<TD align="right">
<INPUT type="submit" value="Submit"></TD>
</TR>
</TABLE>
<P>I should stress that this <EM>isn't</EM> advocating an alternative mechanism for
loading data into controls after postback - this rather contrived demo is
purely to demonstrate that the concept works. A far more common use would
be to handle a (non postback) query request like (for example):</P>
<P>http://somesite/showAccounts.aspx?accountBalanceMin=120&StartDate=2003/01/01&EndDate=2004/01/01</P>
<P> </P>
</form>
</body>
</HTML>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
There's some kinda mutex between money and the time to enjoy it, and it's called work.