Click here to Skip to main content
15,891,905 members
Articles / Web Development / HTML

Runtime Dependent ListBox

Rate me:
Please Sign up or sign in to vote.
3.00/5 (3 votes)
29 May 20071 min read 39.9K   743   18  
This articles describles how to add a Dependent ListBox in Runtime using Ajax (MagicAjax)
<%@ Master Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
	<style type="text/css">
		body
		{ 
			font-family:verdana;
			font-size:small;
			margin-top: 0px;
		}
		fieldset
		{
			width: 700px;
			padding:10px 10px;
		}
		legend
		{
			padding:10px 0px 10px 0px;
		}
	</style>
</head>
<body>
	<form id="form1" runat="server">
		<fieldset>
			<legend><b>MagicAjax.NET Examples for ASP.NET 2.0</b> (.NET version <%= System.Environment.Version %>)<br />Please select one of the demo pages:</legend>
			<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="False" />
			<asp:Menu ID="Menu1" DataSourceID="SiteMapDataSource1" runat="server" StaticSelectedStyle-BorderStyle="Dotted" StaticSelectedStyle-BorderWidth="2px" StaticSelectedStyle-BorderColor="Green" StaticSelectedStyle-Font-Bold="true" />
		</fieldset>
		
		<hr style="border-style:dashed; border-color:black;" />
		
		<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server" />
		
		<ajax:ajaxpanel ID="AjaxSourcePanel" runat="server">
			<br /><hr style="border-style:dashed; border-color:black;" />
			<asp:LinkButton ID="ShowSource" runat="server" Text="Show Source" OnClick="ShowSource_Click" />
			<pre runat="server" id="SourceSpan" style="background-color:PapayaWhip" />
		</ajax:ajaxpanel>
	</form>
</body>
</html>

<script language="C#" runat="server">
	private void Page_Load(object sender, EventArgs e)
	{
		 AjaxSourcePanel.Visible = !Request.RawUrl.ToLowerInvariant().EndsWith("/default.aspx");
	}
	protected void ShowSource_Click(object sender, EventArgs e)
	{
		//read current aspx source, and put in SourceSpan
		SourceSpan.InnerHtml = HttpUtility.HtmlEncode(System.IO.File.ReadAllText(Request.PhysicalPath).Replace("\t", "  "));
	}
</script>

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.

License

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


Written By
Software Developer I.ndigo - www.i.ndigo.com.br
Brazil Brazil
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions