using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace xml
{
/// <summary>
/// WebForm4 的摘要说明。
/// </summary>
public class WebForm4 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.ImageButton ImageButton1;
protected System.Web.UI.WebControls.ListBox ListBox1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ListBox1.SelectedIndexChanged += new System.EventHandler(this.ListBox1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.TextBox1.Text = this.ListBox1.SelectedValue.ToString();
ListBox1.Attributes.Add("onclick","javascript:hidelayer('Layer1');");
}
}
}
===============================
<%@ Page language="c#" Codebehind="WebForm4.aspx.cs" AutoEventWireup="false" Inherits="xml.WebForm4" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm4</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="JavaScript">
function showlayer(id){
if(navigator.appName=="Netscape")
document.layers[id].visibility="show";
else
document.all[id].style.visibility="visible";
}
function hidelayer(id){
if(navigator.appName=="Netscape")
document.layers[id].visibility="hidden";
else
document.all[id].style.visibility="hidden";
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<div id="Layer1" style="Z-INDEX:101; LEFT:300px; VISIBILITY:hidden; WIDTH:280px; POSITION:absolute; TOP:120px; HEIGHT:112px; BACKGROUND-COLOR:rgb(192,192,192)">
<p><font color="#800080">这是第一层,The No.1 Layer</font><font color="#800080">
<asp:ListBox id="ListBox1" runat="server" Width="272px" Height="96px" AutoPostBack="True">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
<asp:ListItem Value="6">6</asp:ListItem>
<asp:ListItem Value="7">7</asp:ListItem>
<asp:ListItem Value="8">8</asp:ListItem>
<asp:ListItem Value="9">9</asp:ListItem>
</asp:ListBox></font></p>
</div>
<asp:TextBox id="TextBox1" style="Z-INDEX: 102; LEFT: 304px; POSITION: absolute; TOP: 80px" runat="server"
Width="192px"></asp:TextBox> <img src="CalendarDD.gif" width="15" height="15" οnclick="javascript:showlayer('Layer1');"
style="Z-INDEX: 104; LEFT: 512px; POSITION: absolute; TOP: 80px">
</form>
</body>
</HTML>