日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 人文社科 > 生活经验 >内容正文

生活经验

asp.net中窗口相关操作总结(javascript)

發(fā)布時(shí)間:2023/11/27 生活经验 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 asp.net中窗口相关操作总结(javascript) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1.打開(kāi)新窗口?
??這個(gè)簡(jiǎn)單:Response.Write(@"<script?
????language=' javascript'>window.open('url');</script>");?
2.關(guān)閉窗口?
??//關(guān)閉當(dāng)前窗口,并提示用戶時(shí)候關(guān)閉,yes關(guān)閉,no退出?
??Response.Write(@"<script?language=' javascript'>window.close();</script>");?
??//延遲關(guān)閉窗口(下面代碼表示2秒后關(guān)閉,無(wú)需確認(rèn))?
??Response.Write(@"<script?
????language=' javascript'>setTimeout('self.close()',2000);</script>");?
3.延遲時(shí)間?
??這個(gè)和上面的沒(méi)有多少區(qū)別.我用到的情況是,在用戶操作完畢給出提示,"n秒后,頁(yè)面?
????轉(zhuǎn)向"之類的只需去掉2重的Self.close()即可?
??Response.Write(@"<script?
????language=' javascript'>setTimeout('',2000);</script>");?
4.彈出提示或警告窗口?
??Response.Write(@"<script?language=' javascript'>alert('添加成功,2秒鐘后頁(yè)面?
????將自動(dòng)跳');</script>");?
5.刷新其他頁(yè)面?
??這個(gè)用到的情況還是不少.比如在B頁(yè)面對(duì)數(shù)據(jù)更新和修改,另一頁(yè)面A要保持最新數(shù)據(jù)?
??給客戶,這是就要在對(duì)B操作完畢的情況下對(duì)A進(jìn)行刷新:?
??Response.Write(@"<script?language=' javascript'>window.opener.location.?
????href='./default.aspx'</script>")?;?
6.頁(yè)面跳轉(zhuǎn)?
??有時(shí)候在學(xué)要給出提示的情況下進(jìn)行頁(yè)面跳轉(zhuǎn),不能使用Response.Redirect("url");?
??比如,當(dāng)客戶操作完畢,單擊按鈕提交,彈出提示框(使用上面3和4),如果使用了?
????Response.Redirect("url");?
??那么頁(yè)面將不給出提示,頁(yè)就是3和4沒(méi)有起作用就直接轉(zhuǎn)向了.?
??如果你是下面的操作過(guò)程:?
??1).Response.Write(@"<script?language=' javascript'>alert('添加成功,2秒鐘后頁(yè)?
????面將自動(dòng)跳');</script>");?
??2).Response.Write(@"<script?
????language=' javascript'>setTimeout('',2000);</script>");?
??3).頁(yè)面轉(zhuǎn)向:?
????Response.Write("<meta?http-equiv='refresh'?
????content='0;URL=./default.aspx'>");?
????//這個(gè)我不知道用 javascript怎么實(shí)現(xiàn),熟悉的輕補(bǔ)充一下?
7.窗口傳制問(wèn)題?
??這個(gè)問(wèn)題比較煩,打開(kāi)模態(tài)窗口(ShowModelDialog)我還沒(méi)有實(shí)現(xiàn),請(qǐng)各位補(bǔ)充.?
??具體情況是這樣的,比如說(shuō)A打開(kāi)一個(gè)新窗口B,當(dāng)用戶對(duì)B操作完畢后,我們獲得必要的?
??數(shù)據(jù),自動(dòng)將其賦給A中的TextBox等控件,這個(gè)過(guò)程是在客戶端完成的.就像發(fā)送郵件時(shí),?
??需要從地址本中選取,然后將選中的發(fā)送地址傳回來(lái).?
??1).在A中加入如下代碼,打開(kāi)一個(gè)新窗口B.?
?????Response.Write(window.">@"window.
????????open('B.aspx','','toolbar=no,menubar=no,status=yes,location=no,?
????????resizable=no,scrollbars=no,width=500,height=350');</script>");?
??2).對(duì)B操作完畢,獲得必要數(shù)據(jù)tmpStr,然后將其賦值給A中的TextBox1?
?????Response.Write(@"<script?
????????language=' javascript'>opener.document.all.TextBox1. value?
?????????='"?+tmpStr+"';</script>");?
??注意:這個(gè)過(guò)程是在客戶單用 javascript完成的,因此我們不能按照服務(wù)端的編程習(xí)慣?
以及不能使用web服務(wù)控件的服務(wù)端屬性進(jìn)行操作.TextBox1是一個(gè)web服務(wù)控件,?
其id為T(mén)extBox1,A頁(yè)面被服務(wù)器解析為html,通過(guò)瀏覽器瀏覽,TextBox1就變成了?
純html控件,我們這里用 javascript操作的也就是html控件,因此賦值使用的是?
TextBox1的 value屬性而不是Text屬性.另外,web服務(wù)器控件的id被解析成html后,?
id有時(shí)會(huì)變,我們只要注意使用服務(wù)器解析后的id就成了,在瀏覽器中右鍵->查看源文件?
即可得到?
?
??對(duì)第七種操作情況最好使用打開(kāi)模態(tài)窗口windows.ShowModelDialog(),但是比較麻煩,?
我還沒(méi)有實(shí)現(xiàn).?
?
?
接上:?
?
調(diào)整本窗口大小和位置?
Response.Write("<script>window.resizeTo(500,400);</script>");?
Response.Write("<script>window.moveTo(300,200);</script>");?
?
?
接上:?
?
補(bǔ):使用模態(tài)窗口傳值?
?
主要代碼如下:?
a.aspx?and?a.aspx.cs?
?
<%@?Page?language="c#"?Codebehind="a.aspx.cs"?AutoEventWireup="false"?
Inherits="Genesis02.a"?%>?
<HTML>?
????<HEAD>?
????????<title>a</title>?
????????<SCRIPT?language=" javascript">?
????????????var?str;?
?
????????????function?pop(url)?
?
????????????{?
????????????????var?myDialog?=?document.a.TBoxType. value;?
?
????????????????if?(window.showModalDialog)?
????????????????{?
????????????????????str=window.showModalDialog(url,myDialog,"dialogHeight:?
300px;?dialogWidth:?500px;center:?yes;?help:?no;resizable:?yes;?status:?
no;");?
????????????????????if?(typeof(str)?!=?"undefined")?
????????????????????{?
????????????????????????document.a.TBoxType. value?=?str;?
????????????????????}?
????????????????}?
????????????}?
????????</SCRIPT>?
????</HEAD>?
????<body?MS_POSITIONING="GridLayout">?
????????<form?id="a"?method="post"?runat="server">?
????????????<asp:textbox?id="TBoxType"?
runat="server"></asp:textbox><asp:button?id="BtnGetType"?Runat="server"?
Text="Open"></asp:button>?
????????</form>?
????</body>?
</HTML>?
__________________________________________________________________?
?
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?Genesis02?
{?
????///?<summary>?
????///?a?的摘要說(shuō)明。?
????///?</summary>?
????public?class?a?:?System.Web.UI.Page?
????{?
????????protected?System.Web.UI.WebControls.TextBox?TBoxType;?
????????protected?System.Web.UI.WebControls.Button?BtnGetType;?
?
????????private?void?Page_Load(object?sender,?System.EventArgs?e)?
????????{?
????????????if?(!IsPostBack)?
?
????????????{?
????????????????BtnGetType.Attributes[" onclick"]?=?"pop('c.aspx');return?
false;";?
????????????}?
????????}?
?
????????#region?Web?Form?Designer?generated?code?
????????override?protected?void?OnInit(EventArgs?e)?
????????{?
????????????//?
????????????//?CODEGEN:該調(diào)用是?ASP.NET?Web?窗體設(shè)計(jì)器所必需的。?
????????????//?
????????????InitializeComponent();?
????????????base.OnInit(e);?
????????}?
?
????????///?<summary>?
????????///?設(shè)計(jì)器支持所需的方法?-?不要使用代碼編輯器修改?
????????///?此方法的內(nèi)容。?
????????///?</summary>?
????????private?void?InitializeComponent()?
????????{?
????????????this.Load?+=?new?System.EventHandler(this.Page_Load);?
?
????????}?
????????#endregion?
????}?
}?
?
?
#################################################################?
b.aspx?and?b.aspx.cs?
?
<%@?Page?language="c#"?Codebehind="b.aspx.cs"?AutoEventWireup="false"?
Inherits="Genesis02.b"?%>?
<HTML>?
????<HEAD>?
????????<title>b</title>?
????????<SCRIPT?language=" javascript">?
????????function?closeme()?
????????{?
?
????????????//top.return value?=?
window.document.all.LBoxRFAContent.options[window.document.all.LBoxRFAContent?
.selectedindex]. value;?
????????????top.return value?=?document.getElementById("TBox value"). value;?
????????????top.close();?
????????}?
?
????????function?Body_Load()?
????????{?
????????????if(window.dialogArguments?!=?null)?{?
????????????????window.document.getElementById("TBox value"). value?=?
window.dialogArguments;?
????????????}?
????????}?
????????</SCRIPT>?
????</HEAD>?
????<body?MS_POSITIONING="GridLayout"?οnlοad="Body_Load()">?
????????<form?id="b"?method="post"?runat="server">?
????????????<asp:Button?id="BtnClose"?style="Z-INDEX:?101;?LEFT:?152px;?
POSITION:?absolute;?TOP:?131px"?runat="server"?Text="Close?me"></asp:Button>?
?
????????????<asp:TextBox?id="TBox value"?style="Z-INDEX:?102;?LEFT:?149px;?
POSITION:?absolute;?TOP:?69px"?runat="server"></asp:TextBox>?
????????</form>?
????</body>?
</HTML>?
?
__________________________________________________________________?
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?Genesis02?
{?
????///?<summary>?
????///?b?的摘要說(shuō)明。?
????///?</summary>?
????public?class?b?:?System.Web.UI.Page?
????{?
????????protected?System.Web.UI.WebControls.TextBox?TBox value;?
????????protected?System.Web.UI.WebControls.Button?BtnClose;?
?
?
????????private?void?Page_Load(object?sender,?System.EventArgs?e)?
????????{?
????????????if?(!IsPostBack)?
????????????{?
????????????????BtnClose.Attributes[" onclick"]?=?"closeme();return?false;";?
????????????}?
????????}?
?
????????#region?Web?Form?Designer?generated?code?
????????override?protected?void?OnInit(EventArgs?e)?
????????{?
????????????//?
????????????//?CODEGEN:該調(diào)用是?ASP.NET?Web?窗體設(shè)計(jì)器所必需的。?
????????????//?
????????????InitializeComponent();?
????????????base.OnInit(e);?
????????}?
?
????????///?<summary>?
????????///?設(shè)計(jì)器支持所需的方法?-?不要使用代碼編輯器修改?
????????///?此方法的內(nèi)容。?
????????///?</summary>?
????????private?void?InitializeComponent()?
????????{?
????????????this.Load?+=?new?System.EventHandler(this.Page_Load);?
?
????????}?
????????#endregion?
????}?
}?
?
#######################################################################?
?
c.aspx?and?c.asp.cs?
?
<%@?Page?language="c#"?Codebehind="c.aspx.cs"?AutoEventWireup="false"?
Inherits="Genesis02.c"?%>?
<HTML>?
?
????<HEAD>?
????????<TITLE>c</TITLE>?
????</HEAD>?
????<frameset?rows="0,*">?
????????<frame?src=" about:blank">?
????????<frame?src="b.aspx">?
????</frameset>?
</HTML>?
?
?
____________________________________________________?
?
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?Genesis02?
{?
?
????///?<summary>?
????///?c?的摘要說(shuō)明。?
????///?</summary>?
????public?class?c?:?System.Web.UI.Page?
????{?
????????private?void?Page_Load(object?sender,?System.EventArgs?e)?
????????{?
????????????//?在此處放置用戶代碼以初始化頁(yè)面?
????????}?
?
????????#region?Web?Form?Designer?generated?code?
????????override?protected?void?OnInit(EventArgs?e)?
????????{?
????????????//?
????????????//?CODEGEN:該調(diào)用是?ASP.NET?Web?窗體設(shè)計(jì)器所必需的。?
????????????//?
????????????InitializeComponent();?
????????????base.OnInit(e);?
????????}?
?
????????///?<summary>?
????????///?設(shè)計(jì)器支持所需的方法?-?不要使用代碼編輯器修改?
????????///?此方法的內(nèi)容。?
????????///?</summary>?
????????private?void?InitializeComponent()?
????????{?
????????????this.Load?+=?new?System.EventHandler(this.Page_Load);?
????????}?
????????#endregion?
????}?
}?
?
#############################################################################?
?
c.aspx?and?c.asp.cs?
?
<%@?Page?language="c#"?Codebehind="c.aspx.cs"?AutoEventWireup="false"?
Inherits="Genesis02.c"?%>?
<HTML>?
????<HEAD>?
????????<TITLE>c</TITLE>?
????</HEAD>?
????<frameset?rows="0,*">?
????????<frame?src=" about:blank">?
????????<frame?src="b.aspx">?
????</frameset>?
</HTML>?
?
?
____________________________________________________?
?
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?Genesis02?
{?
????///?<summary>?
????///?c?的摘要說(shuō)明。?
????///?</summary>?
????public?class?c?:?System.Web.UI.Page?
????{?
????????private?void?Page_Load(object?sender,?System.EventArgs?e)?
????????{?
????????????//?在此處放置用戶代碼以初始化頁(yè)面?
????????}?
?
????????#region?Web?Form?Designer?generated?code?
????????override?protected?void?OnInit(EventArgs?e)?
????????{?
????????????//?
????????????//?CODEGEN:該調(diào)用是?ASP.NET?Web?窗體設(shè)計(jì)器所必需的。?
????????????//?
????????????InitializeComponent();?
????????????base.OnInit(e);?
????????}?
?
????????///?<summary>?
????????///?設(shè)計(jì)器支持所需的方法?-?不要使用代碼編輯器修改?
????????///?此方法的內(nèi)容。?
????????///?</summary>?
????????private?void?InitializeComponent()?
????????{?
????????????this.Load?+=?new?System.EventHandler(this.Page_Load);?
????????}?
????????#endregion?
????}?
}?
?
?
以上是使用模態(tài)窗口的所有主要代碼?
?

總結(jié)

以上是生活随笔為你收集整理的asp.net中窗口相关操作总结(javascript)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。