我们经常需要将数据返回给调用页面,下面是基本实现方式。
假设,有两个页子selectdate.aspx,calendar.aspx.
需要在selectdate.aspx做个连接,点击后打开calendar.aspx,然后在calendar.aspx中选择日期,将选择的日期返回给
selectdate.aspx(呵呵,不知道我说明白没有)
算了,看看代码吧,自然就明白了。
对了,还需要个文件用来装JAVASCRIPT的script.js
===============================================================================================
selectdate.aspx
----------------------------------------
<%@ Page language="c#" Codebehind="detail.aspx.cs" AutoEventWireup="false" Inherits="calendar.detail" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>detail</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript" src="script.js"></script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:TextBox id="CompletionDate" style="Z-INDEX: 101; LEFT: 120px; POSITION: absolute; TOP: 72px"
runat="server"></asp:TextBox>
<A href="javascript:OpenCalendar('CompletionDate', true)"><IMG style="Z-INDEX: 102; LEFT: 296px; WIDTH: 24px; POSITION: absolute; TOP: 72px; HEIGHT: 16px"
height="16" alt="" src=http://www.163design.net/a/s/"img/calendar.gif" width="24"></A>
</form>
</body>
</HTML>
--------------------------------------------------------------------
selectdate.aspx.cs
----------------------------------------------------------------------
sing 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 calendar
{
/// <summary>
/// detail 的摘要说明。
/// </summary>
public class detail : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox CompletionDate;
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.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
===========================================================================
calendar.aspx
=========================================================================
<%@ Page language="c#" Codebehind="calendar.aspx.cs" AutoEventWireup="false" Inherits="calendar.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<m