Click here to Skip to main content
13,739,978 members
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads


95 bookmarked
Posted 2 Mar 2004

Declarative QueryString Parameter Binding

, 2 Mar 2004
Describes using reflection to automatically populate member parameters from the Form and Querystring.
<%@ Page language="c#" Codebehind="WebParameterDemo.aspx.cs" AutoEventWireup="false" Inherits="WebControlTestWeb.WebParameterDemo" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
		<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="">
		<form id="BoundParameterDemo" method="get" runat="server">
			<H1>QueryString parameter binding demo</H1>
			<P>Using the WebParameter attribute, the <STRONG>FirstName</STRONG> and&nbsp;<STRONG>CustomerID</STRONG>
				fields in the underlying page class are 'bound' to <STRONG>txtFirstName</STRONG>
				and&nbsp;<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&nbsp;fields/properties are loaded from the querystring, 
				and&nbsp;the two fields&nbsp;values&nbsp;and the property value are 
				assigned&nbsp;to the controls.
			<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="300" border="1">
					<TD>First Name</TD>
						<INPUT type="text" runat="server" id="txtFirstName"></TD>
					<TD>Last Name</TD>
						<INPUT id="txtLastName" type="text" runat="server"></TD>
					<TD>Customer ID</TD>
						<INPUT id="txtCustomerID" type="text" runat="server"></TD>
					<TD align="right">
						<INPUT type="submit" value="Submit"></TD>
			<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&nbsp;common use would 
				be to handle a (non postback)&nbsp;query request like (for example):</P>

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


About the Author

Web Developer
Australia Australia
There's some kinda mutex between money and the time to enjoy it, and it's called work.

You may also be interested in...

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web05-2016 | 2.8.180920.1 | Last Updated 3 Mar 2004
Article Copyright 2004 by piers7
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid