<TD background="common/btnimg/tool_bar.gif" height="21">菜单列表</TD>
background可否像img属性那样width=100%,让它铺满整个单元格,而这样只能图片宽度和单元格宽度一致才行,如让它平铺,它会重叠铺同一幅图.
2个问题:
在a.aspx页面里用showmodaldialog打开b.aspx,如何在关闭b.aspx时刷新a.aspx,我在网上找了很久也没找到.请哪位高手帮一下.
background可否像img属性那样width=100%,让它铺满整个单元格,而这样只能图片宽度和单元格宽度一致才行,如让它平铺,它会重叠铺同一幅图.
2个问题:
在a.aspx页面里用showmodaldialog打开b.aspx,如何在关闭b.aspx时刷新a.aspx,我在网上找了很久也没找到.请哪位高手帮一下.
2、
Step #1 - Create a C# ASP.Net app and name it "ShowModalDialogCS".
Step #2 - Add 3 web fomrs, WebForm1, WebForm2 and WebForm3.
Step #3 - Copy and paste the below code.
WebForm1.aspx
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="ShowModalDialogCS.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">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<div align="center">
<form id="Form1" method="post" runat="server">
<asp:label id="Label1" runat="server" Font-Bold="true">
Open a pop-up window, input a value. It can be used repeatly.
</asp:label><br>
<br>
<asp:textbox id="TextBox1" runat="server" Width="600px">Initial value, it will be passed into the pop up window</asp:textbox><br>
<br>
<asp:button id="Button1" runat="server" Text="Open Pop-up window" Width="262px"></asp:button></form>
</div>
</body>
</HTML>WebForm1.aspx.cs (Codebehind file)
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 ShowModalDialogCS
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.HtmlControls.HtmlForm Form1;private void Page_Load(object sender, System.EventArgs e)
{
if ((!(IsClientScriptBlockRegistered("clientScript"))))
{
string strScript = "<script>" + "\r\n";
strScript += "function OpenWin(){" + "\r\n";
strScript += "var str=window.showModalDialog('WebForm2.aspx',document.Form1.TextBox1.value)" + "\r\n";
strScript += "if(str!=null) document.Form1.TextBox1.value=str" + "\r\n";
strScript += "}" + "\r\n";
strScript += "</script>" + "\r\n";
RegisterClientScriptBlock("clientScript", strScript);
}
Button1.Attributes.Add("onclick", "OpenWin()"); }#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);}
#endregion
}
}WebForm2.aspx
<%@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="ShowModalDialogCS.WebForm2" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<TITLE>WebForm2</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">
</HEAD>
<frameset rows="0,*">
<frame src="about:blank">
<frame src="http://localhost/ShowModalDialogCS/WebForm3.aspx">
</frameset>
</HTML>WebForm2.aspx.cs (Code Behind file)
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 ShowModalDialogCS
{
/// <summary>
/// Summary description for WebForm2.
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}WebForm3.aspx
<%@ Page language="c#" Codebehind="WebForm3.aspx.cs" AutoEventWireup="false" Inherits="ShowModalDialogCS.WebForm3" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm3</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">
</HEAD>
<body MS_POSITIONING="GridLayout" id="MyBody" runat="server">
<form id="Form1" method="post" runat="server">
<asp:Label id="Label1" runat="server">Your Name: </asp:Label><br>
<br>
<asp:TextBox id="TextBox1" runat="server" Width="558"></asp:TextBox><br>
<br>
<asp:Button id="Button1" runat="server" Text="Submit" style="Z-INDEX: 101; LEFT: 24px; POSITION: absolute; TOP: 88px"></asp:Button>
</form>
</body>
</HTML>WebForm3.aspx.cs (Code Behind file)
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 ShowModalDialogCS
{
/// <summary>
/// Summary description for WebForm3.
/// </summary>
public class WebForm3 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Label Label1;protected System.Web.UI.HtmlControls.HtmlControl MyBody;private void Page_Load(object sender, System.EventArgs e)
{
if (IsPostBack)
{
string strScript = "<script>" + "\r\n";
strScript += "window.parent.returnValue='" + TextBox1.Text.Replace("'", "\\'") + "'" + "\r\n";
strScript += "window.parent.close()" + "\r\n";
strScript += "</script>" + "\r\n";
if ((!(IsClientScriptBlockRegistered("clientScript"))))
{
RegisterClientScriptBlock("clientScript", strScript);
}
}
if (!(IsPostBack))
{
MyBody.Attributes.Add ("onload", "document.Form1.TextBox1.value=window.parent.dialogArguments");
} }#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);}
#endregion
}
}
window.parent.href.reload();
或者
window.open('b.aspx','_parent');
window.opener.location.reload();
2.<body onUnload="javascript:window.opener.location.reload();">
该如何办呢?