當前子窗口的cs代碼 using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using Microsoft.VisualBasic;public partial class Dispatch : System.Web.UI.Page { private linmoug.DataLogic.DataLogic dl = new linmoug.DataLogic.DataLogic(); private linmoug.BusinessLogic.BusLogic bl = new linmoug.BusinessLogic.BusLogic(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) {
當前父窗口的cs代碼 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; using System.Data.SqlClient; using System.Web.Mail;namespace Purchase { public partial class BuyList : System.Web.UI.Page { private linmoug.DataLogic.DataLogic dl = new linmoug.DataLogic.DataLogic(); private linmoug.BusinessLogic.BusLogic bl = new linmoug.BusinessLogic.BusLogic();
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using Microsoft.VisualBasic;public partial class Dispatch : System.Web.UI.Page { private linmoug.DataLogic.DataLogic dl = new linmoug.DataLogic.DataLogic(); private linmoug.BusinessLogic.BusLogic bl = new linmoug.BusinessLogic.BusLogic(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) {
//提个思路,不知道你是不是要这个意思
function check()
{
//略
}function tijiao()
{
if(check)
关闭
}
function 取消()
{
if(!check)
关闭
}
<script>
var IsOk=false;
window.onunload=function()
{
if(IsOk)
opener.document.getElementById("a窗口複選框ID").checked=true;
else
opener.document.getElementById("a窗口複選框ID").checked=false;
}
</script>
<input type="button" value="提交" onclick="IsOk=true;window.close()"/>
<input type="button" value="取消" onclick="window.close()"/>
<head runat="server">
<title>无标题页</title>
<script>
function change(obj)
{
if(obj.checked)
window.open('tempB.aspx');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<label for="ckb"><input type="checkbox" id="ckb" onclick="change(this)" />选择</label>
</div>
</form>
</body>
</html>tempB
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="tempB.aspx.cs" Inherits="tempB" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script>
function ret(obj)
{
if(obj.id=='btnOK')
{
window.opener.document.getElementById('ckb').checked=true;
window.close();
}
else
{
window.opener.document.getElementById('ckb').checked=false;
window.close();
}
}
function bUnload()
{
window.opener.document.getElementById('ckb').checked=false;
}
</script>
</head>
<body onbeforeunload="bUnload();">
<form id="form1" runat="server">
<div>
<input type="button" id="btnOK" value="确定" onclick="ret(this)" />
<input type="button" id="btnCancel" value="取消" onclick="ret(this)" />
</div>
</form>
</body>
</html>
function openb()
{
openPath = "b窗口路径";
attribute= "status:no;center:yes;help:no;minimize:no;maximize:no;dialogWidth:488px;dialogHeight:238px;scroll:no;border:think";
var returnValue = window.showModalDialog(openPath,null,attribute)
if ( returnValue != null )
{
document.getElementById("a窗口複選框ID").checked=true;
}
else
{
//不刷新a窗口(點X那個圖標或者雙擊左上角)
document.getElementById("a窗口複選框ID").checked=false;
}
}2、在b窗口中,若是想刷新a窗口,则在事件里写上:
string script = "<script language=javascript>returnValue=notnull;window.close();</script>";this.Page.RegisterStartupScript("close", script);
否则(不刷新a窗口的话):
string script = "<script language=javascript>returnValue=null;window.close();</script>";this.Page.RegisterStartupScript("close", script);
<script>
var flag=0;
function ret(obj)
{
if(obj.id=='btnOK')
{
flag=1;
window.opener.document.getElementById('ckb').checked=true;
window.close();
}
else
{
window.opener.document.getElementById('ckb').checked=false;
window.close();
}
}
function bUnload()
{
if(flag!=1)
window.opener.document.getElementById('ckb').checked=false;
}
</script>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Dispatch.aspx.cs" Inherits="Dispatch"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
var flag=0;
function ret(obj)
{
if(obj.id=='btn_Submit')
{
flag=1;
window.opener.document.getElementById('ckb').checked=true;
window.close();
}
else
{
window.opener.document.getElementById('ckb').checked=false;
window.close();
}
}
function bUnload()
{
if(flag!=1)
window.opener.document.getElementById('ckb').checked=false;
}
</script></head>
<body onbeforeunload="bUnload();">
<form id="form1" runat="server">
<div>
<table width="100%" style="position: static">
<tr>
<td align="left" colspan="2">
<img style="POSITION: static;" alt="" src="image/Dot(blue).jpg"/>
<asp:Label ID="lbl_Dispatch" runat="server" Font-Size="Small" ForeColor="Blue" Style="position: static"
Text="急件信息"></asp:Label>
<hr style="WIDTH: 14%; POSITION: static; HEIGHT: 1px" size="1"/>
</td>
</tr>
<tr>
<td style="width: 20%; height: 26px; text-align: right;">
<asp:Label ID="lbl_DispatchName" runat="server" Style="position: static" Text="急件名稱:" ForeColor="Blue"></asp:Label></td>
<td style="height: 26px">
<asp:TextBox ID="txt_DispatchName" runat="server" Style="position: static"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 20%; text-align: right">
<asp:Label ID="lbl_DispatchRe" runat="server" ForeColor="Blue" Style="position: static" Text="說明內容:"></asp:Label></td>
<td>
<asp:TextBox ID="txt_DispatchRe" runat="server" Height="80px" Style="position: static"
TextMode="MultiLine" Width="400px"></asp:TextBox>
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="btn_Submit" runat="server" Style="position: static" Text="提 交" OnClick="ret(this)" />
<asp:Button ID="btn_Cancel" runat="server" Style="position: static" Text="取 消" OnClick="ret(this)" /></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
</table>
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.VisualBasic;public partial class Dispatch : System.Web.UI.Page
{
private linmoug.DataLogic.DataLogic dl = new linmoug.DataLogic.DataLogic();
private linmoug.BusinessLogic.BusLogic bl = new linmoug.BusinessLogic.BusLogic(); protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
} #region 返回父窗口,關閉當前窗口 wkk 2008-5-16
private void thisClose()
{
this.Response.Write("<script>window.close()</script>");
}
protected void btn_Cancel_Click(object sender, EventArgs e)
{
this.thisClose();
}
#endregion #region
private void SubmitDispatchInfo()
{
string DispatchName = this.txt_DispatchName.Text.ToString().Trim();
string DispatchRe = this.txt_DispatchRe.Text.ToString().Trim();
string strSqlInsert = "insert into tbDispatch(name,re)values('"+DispatchName+"','"+DispatchRe+"')";
dl.ExcuteSql(strSqlInsert);
}
#endregion
protected void btn_Submit_Click(object sender, EventArgs e)
{
this.SubmitDispatchInfo();
bl.Alert("新增成功!",Page);
}
}
<asp:DataGrid id="DataGrid" runat="server" BorderWidth="1px" BorderStyle="None" AutoGenerateColumns="False"
CellPadding="3" BackColor="White" BorderColor="#E7E7FF" Width="864px" GridLines="Horizontal"
Font-Size="X-Small" Height="25px" style="Z-INDEX: 109; LEFT: 8px; POSITION: absolute; TOP: 55px">
<FooterStyle ForeColor="#4A3C8C" BackColor="#B5C7DE"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#738A9C"></SelectedItemStyle>
<AlternatingItemStyle BackColor="#F7F7F7"></AlternatingItemStyle>
<ItemStyle ForeColor="#4A3C8C" BackColor="#E7E7FF"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#4A3C8C"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="急件">
<HeaderTemplate>
<asp:CheckBox
ID="cb_Dispatch" runat="server" Font-Size="X-Small" ForeColor="Red" Style="position: static;"
Text="急 件" Width="60px" AutoPostBack="True" onclick="change(this)" Height="16px" />
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lbl_Dispatch" runat="server" Style="position: static"></asp:Label>
</ItemTemplate>
<HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" Wrap="False" />
<ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" Wrap="False" />
</asp:TemplateColumn>
<asp:BoundColumn DataField="DEPARTMENT" ReadOnly="True" HeaderText="部門"></asp:BoundColumn>
<asp:BoundColumn DataField="REQUESTER" ReadOnly="True" HeaderText="Owner"></asp:BoundColumn>
<asp:BoundColumn DataField="MAT_ID" ReadOnly="True" HeaderText="料號"></asp:BoundColumn>
<asp:BoundColumn DataField="GOOD_NAME" ReadOnly="True" HeaderText="品名"></asp:BoundColumn>
<asp:BoundColumn DataField="GOOD_TYPE" ReadOnly="True" HeaderText="規格"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="數量">
<ItemTemplate>
<asp:Label id="Label1" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.GOOD_COUNT") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txt_GoodCount" runat="server" Width="48px" Text='<%# DataBinder.Eval(Container, "DataItem.GOOD_COUNT") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="說明">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.REASON") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.REASON") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton id="LinkButton1" runat="server" Text="編輯" CommandName="Edit" CausesValidation="false"></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton id="LinkButton3" runat="server" Text="更新" CommandName="Update" CausesValidation="False">更新</asp:LinkButton>
<asp:LinkButton id="LinkButton2" runat="server" Text="取消" CommandName="Cancel" CausesValidation="false"></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton id="LinkButton4" runat="server" Text="刪除" CommandName="Delete" CausesValidation="false"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="細目">
<ItemTemplate>
<a href='GoodDetailsNew.aspx?mat_id=<%# DataBinder.Eval(Container,"Dataitem.MAT_ID")%>&pr_temp=<%# DataBinder.Eval(Container,"Dataitem.DETAILS_PR_TEMP")%>' target="_blank">細目</a>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="DETAILS_PR_TEMP" HeaderText="臨時單號" ReadOnly="True" Visible="False">
</asp:BoundColumn>
</Columns>
<PagerStyle HorizontalAlign="Right" ForeColor="#4A3C8C" BackColor="#E7E7FF" Mode="NumericPages"></PagerStyle>
</asp:DataGrid>
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;
using System.Data.SqlClient;
using System.Web.Mail;namespace Purchase
{
public partial class BuyList : System.Web.UI.Page
{
private linmoug.DataLogic.DataLogic dl = new linmoug.DataLogic.DataLogic();
private linmoug.BusinessLogic.BusLogic bl = new linmoug.BusinessLogic.BusLogic();
protected void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
DataGridBind();
}
}
public void DataGridBind()
{
string department = Convert.ToString(Session["department"]);
string requester = Convert.ToString(Session["name"]); string strSql = "select tbPRTempXZ.DEPARTMENT, tbPRTempXZ.REQUESTER,tbPRTempXZ.MAT_ID,tbGoodXZ.GOOD_NAME,tbGoodXZ.GOOD_TYPE,tbPRTempXZ.GOOD_COUNT,tbPRTempXZ.REASON,tbPRTempXZ.DETAILS_PR_TEMP "
+ "from tbPRTempXZ INNER JOIN tbGoodXZ ON tbPRTempXZ.MAT_ID = tbGoodXZ.MAT_ID and tbPRTempXZ.DEPARTMENT = '" + department + "' and tbPRTempXZ.REQUESTER = '" + requester + "'";
dl.DataGridBind(strSql,this.DataGrid);
} private void DataGrid_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
this.DataGrid.EditItemIndex = e.Item.ItemIndex;
DataGridBind();
} private void DataGrid_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string department = e.Item.Cells[0].Text.ToString().Trim();
string requester = e.Item.Cells[1].Text.ToString().Trim();
string mat_id = e.Item.Cells[2].Text.ToString().Trim();
string good_count = ((System.Web.UI.WebControls.TextBox)e.Item.Cells[5].Controls[1]).Text.ToString();
string reason = ((System.Web.UI.WebControls.TextBox)e.Item.Cells[6].Controls[1]).Text.ToString();
string UpdateSql = "update tbPRTempXZ set GOOD_COUNT = '"+good_count+"', REASON = '"+reason+"' where MAT_ID = '"+mat_id+"' and DEPARTMENT = '"+department+"' and REQUESTER = '"+requester+"'";
dl.ExcuteSql(UpdateSql); DataGrid.EditItemIndex = -1;
DataGridBind();
} private void DataGrid_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DataGrid.EditItemIndex = -1;
DataGridBind();
} private void DataGrid_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string department = e.Item.Cells[0].Text.ToString().Trim();
string requester = e.Item.Cells[1].Text.ToString().Trim();
string mat_id = e.Item.Cells[2].Text.ToString().Trim();
string DeleteSql = "delete from tbPRTempXZ where DEPARTMENT = '"+department+"' and REQUESTER = '"+requester+"' and MAT_ID = '"+mat_id+"'";
dl.ExcuteSql(DeleteSql); DataGrid.EditItemIndex = -1;
DataGridBind();
} protected void LinkBtn_Submit_Click(object sender, System.EventArgs e)
{
string department = Convert.ToString(Session["department"]);
string requester = Convert.ToString(Session["name"]);
string date_exp = bl.ChangeDateFormat(this.txt_Date.Text.Trim());
string date_pr = bl.convertdate(System.DateTime.Now.ToShortDateString().Trim());
string cur_month = bl.convertdate(System.DateTime.Now.ToShortDateString().Trim()).Substring(0,7);
string strGetMGNameSql = "select NAME from tbUser where DEPARTMENT = '"+department+"' and DUTY = '主管'";
string strGetMGMailSql = "select email from tbUser where DEPARTMENT = '" + department + "' and DUTY = '主管'";
string strMGName = dl.ExcuteScalar(strGetMGNameSql).ToString();
string strMGMail = dl.ExcuteScalar(strGetMGMailSql).ToString(); string pr_id = bl.GetNewPRId(Convert.ToString(2));
string strSql1 = "SELECT tbPRTempXZ.MAT_ID,tbPRTempXZ.GOOD_COUNT,tbGoodXZ.FATHER, tbPRTempXZ.REASON ,tbGoodXZ.GOOD_NAME, tbGoodXZ.GOOD_TYPE,tbGoodXZ.UNIT,tbGoodXZ.BRAND from tbPRTempXZ,tbGoodXZ where tbPRTempXZ.MAT_ID = tbGoodXZ.MAT_ID and tbPRTempXZ.DEPARTMENT = '" + department + "' and tbPRTempXZ.REQUESTER = '" + requester + "'";
bool ifexist = dl.IfRecordExist(strSql1);
if(!ifexist)
Response.Write("<script>alert('對不起,您沒有選取任何物件,提交數據不能為空!')</script>");
else
{
SqlDataReader reader1 = dl.ExcuteReader(strSql1);
while(reader1.Read())
{
string mat_id = reader1.GetString(0).Trim();
decimal good_count = reader1.GetDecimal(1);
string father = reader1.GetString(2).Trim();
string reason = reader1.GetString(3).Trim();
string good_name = reader1.GetString(4).Trim();
string good_type = "無";
if (reader1[5].ToString() != string.Empty)
{
good_type = reader1.GetString(5).Trim();
}
string unit = reader1.GetString(6).Trim();
string brand = reader1.GetString(7).Trim();
string buyer = dl.ExcuteScalar("select buyer from tbclass inner join tbGoodxz on tbGoodXZ.father = tbclass.class_ID and tbGoodXZ.mat_id = '"+mat_id+"'"); string insertSql1 = "";
insertSql1 = "insert tbPRXZ (PR_ID,FATHER,CUR_MONTH,DEPARTMENT,REQUESTER,MAT_ID,GOOD_NAME,GOOD_TYPE,GOOD_COUNT,UNIT,DATE_PR,DATE_EXP,MG_CHECK,SM_CHECK,VP_CHECK,PR_STATUS,PRICE,MONEY_TYPE,SUPPLIER,PO_ID,REMARK,REASON,SM_NAME,BRAND,BILL_ID,BUYER)"
+ "values ('" + pr_id + "','" + father + "','" + cur_month + "','" + department + "','" + requester + "','" + mat_id + "','" + good_name + "','" + good_type + "','" + good_count + "','" + unit + "','" + date_pr + "','" + date_exp + "','未審核','未審核','未審核','待主管審核','0.00','',' ',' ','','" + reason + "','" + strMGName + "','" + brand + "','NO','" + buyer + "')";
dl.ExcuteSql(insertSql1);
}
reader1.Close();
bl.AddAction("提交一筆請購單,單號:"+pr_id+"");
string thisMonth = "";
if (DateTime.Now.Month.ToString().Length == 1)
{
thisMonth = "0" + DateTime.Now.Month.ToString();
}
else
{
thisMonth = DateTime.Now.Month.ToString();
}
string thisCur_month = DateTime.Now.Year.ToString() + "/" + thisMonth;
dl.ExcuteSql("update tbGoodDetails set PR_ID = '" + pr_id + "' where PR_ID = (select distinct DETAILS_PR_TEMP from tbPRTempXZ where DEPARTMENT = '" + department + "' and REQUESTER = '" + requester + "' and cur_month='"+thisCur_month+"')");
string delSql = "delete tbPRTempXZ where DEPARTMENT = '"+department+"' and REQUESTER = '"+requester+"'";
dl.ExcuteSql(delSql);
DataGridBind(); Response.Write("<script>alert('您的採購清單已經提交成功!單號為" + pr_id + ";下一步請找您的部門主管審核!')</script>");
}
}
<asp:Button ID="btn_Submit" runat="server" Style="position: static" Text="提 交" OnClick="ret(this)" />
<asp:Button ID="btn_Cancel" runat="server" Style="position: static" Text="取 消" OnClick="ret(this)" />改成<asp:Button ID="btn_Submit" runat="server" Style="position: static" Text="提 交" OnClick="btn_Submit_Click" />
<asp:Button ID="btn_Cancel" runat="server" Style="position: static" Text="取 消" OnClientClick="ret(this);return false;" />
var flag=0;
function ret(obj)
{
if(obj.id=='btn_Submit')
{
flag=1;
window.opener.document.getElementById('ckb').checked=true;
window.close();
}
else
{
window.opener.document.getElementById('ckb').checked=false;
window.close();
}
}
function bUnload()
{
if(flag!=1)
window.opener.document.getElementById('ckb').checked=false;
}
</script> 改成: <script type="text/javascript">
var flag=0;
function bUnload()
{
if(flag!=1)
window.opener.document.getElementById('ckb').checked=false;
}
</script>
<asp:Button ID="btn_Cancel" runat="server" Style="position: static" Text="取 消" OnClick="ret(this)" /> 改成:<asp:Button ID="btn_Cancel" runat="server" Style="position: static" Text="取 消"
OnClientClick=" window.close();return false;"/>
2、后台添加下面代码
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.hddTemp.Attributes.Add("onPropertyChange","DoChange();");
}
else
{
if (Request["__EVENTTARGET"]=="hddTemp") //注意写法,__EVENTTARGET是两个相连的下划线,别写成了_EVENTTARGET
{
//自定义回传
ChangeData()
RefreshData();
}
}
}
<asp:Button ID="btn_Submit" runat="server" Style="position: static" Text="提 交" OnClick="ret(this)" />
改成:<asp:Button ID="btn_Submit" runat="server" Style="position: static" Text="提 交"
OnClick="btn_Submit_Click" />
protected void btn_Submit_Click(object sender, EventArgs e)
{
this.SubmitDispatchInfo();
bl.Alert("新增成功!",Page);
} protected void btn_Submit_Click(object sender, EventArgs e)
{
this.SubmitDispatchInfo();
bl.Alert("新增成功!",Page);
ClientScript.RegisterStartupScript(GetType(), "close", "<script>flag=1;window.close();</script>");
}貌似你的bl 里就会有类似的封装方法。
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
var flag=0;
function bUnload()
{
if(flag!=1)
window.opener.document.getElementById('ckb').checked=false;
}
</script> </head>
<body>
<form id="form1" runat="server">
<div>
<table width="100%" style="position: static">
<tr>
<td align="left" colspan="2">
<img style="POSITION: static;" alt="" src="image/Dot(blue).jpg"/>
<asp:Label ID="lbl_Dispatch" runat="server" Font-Size="Small" ForeColor="Blue" Style="position: static"
Text="急件信息"></asp:Label>
<hr style="WIDTH: 14%; POSITION: static; HEIGHT: 1px" size="1"/>
</td>
</tr>
<tr>
<td style="width: 20%; height: 26px; text-align: right;">
<asp:Label ID="lbl_DispatchName" runat="server" Style="position: static" Text="急件名稱:" ForeColor="Blue"></asp:Label></td>
<td style="height: 26px">
<asp:TextBox ID="txt_DispatchName" runat="server" Style="position: static"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 20%; text-align: right">
<asp:Label ID="lbl_DispatchRe" runat="server" ForeColor="Blue" Style="position: static" Text="說明內容:"></asp:Label></td>
<td>
<asp:TextBox ID="txt_DispatchRe" runat="server" Height="80px" Style="position: static"
TextMode="MultiLine" Width="400px"></asp:TextBox>
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="btn_Submit" runat="server" Style="position: static" Text="提 交" OnClick="btn_Submit_Click" />
<asp:Button ID="btn_Cancel" runat="server" Style="position: static" Text="取 消" OnClick="btn_Cancel_Click"/></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
</table>
</div>
</form>
</body>
</html>
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.VisualBasic;public partial class Dispatch : System.Web.UI.Page
{
private linmoug.DataLogic.DataLogic dl = new linmoug.DataLogic.DataLogic();
private linmoug.BusinessLogic.BusLogic bl = new linmoug.BusinessLogic.BusLogic(); protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
} #region 返回父窗口,關閉當前窗口 wkk 2008-5-16
private void thisClose()
{
this.Response.Write("<script>window.close()</script>");
}
protected void btn_Cancel_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(GetType(), "close", "<script>flag=false;window.close();</script>"); //this.thisClose();
}
#endregion #region
private void SubmitDispatchInfo()
{
string DispatchName = this.txt_DispatchName.Text.ToString().Trim();
string DispatchRe = this.txt_DispatchRe.Text.ToString().Trim();
string strSqlInsert = "insert into tbDispatch(name,re)values('"+DispatchName+"','"+DispatchRe+"')";
dl.ExcuteSql(strSqlInsert);
}
#endregion
protected void btn_Submit_Click(object sender, EventArgs e)
{
this.SubmitDispatchInfo();
bl.Alert("新增成功!",Page);
ClientScript.RegisterStartupScript(GetType(), "close", "<script>flag=1;window.close();</script>");
}
}
<body onbeforeunload="bUnload();">
<asp:Button ID="btn_Cancel" runat="server" Style="position: static" Text="取 消"
OnClientClick=" flag=0;window.close();return false;"/>