欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp.net彈出窗口 返回值

 更新時間:2014年01月15日 15:38:54   作者:  
這篇文章主要介紹了asp.net彈出窗口 返回值,有需要的朋友可以參考一下

Page.aspx:

復(fù)制代碼 代碼如下:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>無標(biāo)題頁</title>
<script type="text/javascript" >...
function Pop()
...{
var result=showModalDialog('downs.aspx','subpage','dialogWidth:400px;dialogHeight:300px;center:yes;help:no;resizable:no;status:no'); //打開模態(tài)子窗體,并獲取返回值
document.getElementById("txt_id").value=result.split("'")[0]; //返回值分別賦值給相關(guān)文本框
document.getElementById("txt_name").value=result.split("'")[1];
document.getElementById("txt_pwd").value=result.split("'")[2];
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txt_id" runat="server" ></asp:TextBox>
<asp:TextBox ID="txt_name" runat="server" ></asp:TextBox>
<asp:TextBox ID="txt_pwd" runat="server" ></asp:TextBox>
<br />

<asp:Button ID="btnPop" runat="server" Text="PoPWindows" />

</div>
</form>
</body>
</html>

downs.aspx: 彈出頁面

復(fù)制代碼 代碼如下:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>無標(biāo)題頁</title>
<script type="text/javascript" >...
function cc(infor_id,infor_name,infor_psw) //參數(shù)分別為id,name和password
...{
window.returnValue= infor_id+"'"+infor_name+"'"+infor_psw; //返回值
window.close();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="gvshow" runat="server" BackColor="White" BorderColor="#CCCCCC"
BorderStyle="None" BorderWidth="1px" CellPadding="3"
>
<FooterStyle BackColor="White" ForeColor="#000066" />
<RowStyle ForeColor="#000066" />
<PagerStyle BackColor="White" ForeColor="#000066" Horiz />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
</asp:GridView>
</div>
</form>
</body>
</html>

downs.cs:彈出頁面后臺代碼:

復(fù)制代碼 代碼如下:

public partial class downs : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SetBind();
}
}
public void SetBind()
{
string ConnString = ConfigurationManager.ConnectionStrings["ConnStr"].ToString();
using (SqlConnection conn = new SqlConnection(ConnString))
{
conn.Open();
string sql = "select top 10 gwid,machtype,isok from allinfor";
SqlDataAdapter ada = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
ada.Fill(ds);
gvshow.DataSource = ds.Tables[0];
this.gvshow.DataBind();
}
}
protected void gvshow_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", "cc('" + e.Row.Cells[0].Text + "','" + e.Row.Cells[1].Text + "','" + e.Row.Cells[2].Text + "')");
}
}
}

第二種方式:

returnValue是javascript中html的window對象的屬性,目的是返回窗口值,當(dāng)用
window.showModalDialog函數(shù)打開一個IE的模式窗口(模式窗口知道吧,就是打開后不能操作父窗口,只能等模式窗口關(guān)閉時才能操作)時,用于返回窗口的值,下面舉個例子:

復(fù)制代碼 代碼如下:

//father.html
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<script language="javascript">

function showmodal(){
var ret = window.showModalDialog("child.htm",null,"dialogWidth:350px;dialogHeight:350px;help:no;status:no");
if (ret){alert('子窗口返回真!');
}else{
alert('子窗口返回假!');
}

}

</script>
</HEAD>
<BODY>
<INPUT id=button1 type=button value=Button name=button1 onclick="showmodal();">

</BODY>
</HTML>

復(fù)制代碼 代碼如下:

//child.html
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<script language="javascript">
function trans(tag){

   if (tag==0){
     window.returnValue=false;
   } else{
     window.returnValue =true;
   }
   window.close();

}


</script>
</HEAD>
<BODY>

<INPUT id=button1 type=button value="返回真" name=button1 onclick="trans(1)">
<INPUT id=button2 type=button value="返回假" name=button2 onclick="trans(0)">

</BODY>
</HTML>

這樣一來可以實現(xiàn)從模式窗口向父窗口傳遞值的作用,
這個returnValue除了可以是布爾值,整型值等以外還可以是個js數(shù)組,用來傳遞大量數(shù)據(jù)。
具體showModalDialog等的用法,可以參考msdn。

 

注意下面的有opener的都只能是用在window.open()這種情況而不能是上面.的showModel...等形式否則的話.會報undetife錯誤....


也可以這樣子的改變父窗口中的值. 下面的這個..可以動態(tài)改變父窗口中多個值.而不是簡單的把彈出窗口中的一個選中以后.馬上就傳回去給父窗口.


opener.document.getElementById('txt_Phone').value = Number;
        opener.document.getElementById('hdn_ID').value = ID;
        opener.document.getElementById('hdn_Phone').value = Number;
        window.close();


加上這句.我們還可以.刷新父窗口
window.opener.location.href=window.opener.location.href
window.opener.location.reload()

如果還要調(diào)用父窗口中的方法.也可以用下面的這種..如下
     opener.函數(shù)名(xxx,xxx)  
不過函數(shù)內(nèi)變量的作用域仍為父窗體.
這樣子我們.就可以直接調(diào)用這個函數(shù)..如果這個函數(shù)是異步請求的那就更爽了..
也就是說我們.在子窗口中可以向服務(wù)器發(fā)送請求..關(guān)閉子窗口后..我們父窗口又立即向服務(wù)器發(fā)送異步請求.又窗口雙請求.

相關(guān)文章

  • ASP.NET MVC 導(dǎo)出Word報表

    ASP.NET MVC 導(dǎo)出Word報表

    本文主要介紹了ASP.NET MVC 導(dǎo)出Word報表的方法,具有很好的參考價值,下面跟著小編一起來看下吧
    2017-02-02
  • 分享Visual Studio原生開發(fā)的10個調(diào)試技巧(2)

    分享Visual Studio原生開發(fā)的10個調(diào)試技巧(2)

    這篇文章又為大家分享了Visual Studio原生開發(fā)的10個調(diào)試技巧,感興趣的朋友可以參考一下
    2015-11-11
  • asp.net實現(xiàn)的DES加密解密操作示例

    asp.net實現(xiàn)的DES加密解密操作示例

    這篇文章主要介紹了asp.net實現(xiàn)的DES加密解密操作,結(jié)合具體實例形式分析了asp.net實現(xiàn)DES加密與解密算法的實現(xiàn)技巧,需要的朋友可以參考下
    2017-07-07
  • 淺談ASP.NET Core 2.0 帶初始參數(shù)的中間件(譯)

    淺談ASP.NET Core 2.0 帶初始參數(shù)的中間件(譯)

    這篇文章主要介紹了淺談ASP.NET Core 2.0 帶初始參數(shù)的中間件(譯),非常具有實用價值,需要的朋友可以參考下
    2017-10-10
  • WinForm中窗體間的數(shù)據(jù)傳遞交互的一些方法

    WinForm中窗體間的數(shù)據(jù)傳遞交互的一些方法

    通過子窗口向外引發(fā)一個事件,父窗口去實現(xiàn)該事件,我們可以再不關(guān)閉父窗口和子窗口的情況下進(jìn)行數(shù)據(jù)的傳輸顯示
    2012-12-12
  • ASP.NET中實現(xiàn)文件的保護(hù)性下載基礎(chǔ)篇

    ASP.NET中實現(xiàn)文件的保護(hù)性下載基礎(chǔ)篇

    許多時候,我們需要在因特網(wǎng)上提供文件下載服務(wù),但是又要防止未經(jīng)授權(quán)的下載,這時該怎么辦?本文將為讀者詳細(xì)介紹一種使用ASP.NET實現(xiàn)的HTTP處理程序的解決方案。
    2011-02-02
  • 快速入門ASP.NET Core看這篇就夠了

    快速入門ASP.NET Core看這篇就夠了

    ASP.NET Core 是一個由微軟創(chuàng)建的,用于構(gòu)建 web 應(yīng)用、API、微服務(wù) 的 web 框架。通過本文的學(xué)習(xí)就能快速的入門ASP.NET Core,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • .NET 單點登錄解決方案

    .NET 單點登錄解決方案

    這里指的單點,泛指在WEB服務(wù)端,一個賬戶同一時刻只能存在一個票據(jù)!怎么使同一個用戶,在同一時間內(nèi)只允許登錄一次,下面將為大家詳細(xì)介紹下
    2013-10-10
  • gridview checkbox從服務(wù)器端和客戶端兩個方面實現(xiàn)全選和反選

    gridview checkbox從服務(wù)器端和客戶端兩個方面實現(xiàn)全選和反選

    GridView中的checkbox的全選和反選在很多的地方都是要求實現(xiàn)的,所以下面就從服務(wù)器端和客戶端兩個方面實現(xiàn)了checkbox的選擇,感興趣的朋友可以了解下,希望本文對你有所幫助
    2013-01-01
  • GridView自動增加序號(三種實現(xiàn)方式)

    GridView自動增加序號(三種實現(xiàn)方式)

    第一種方式,直接在Aspx頁面GridView模板列中.這種的缺點是到第二頁分頁時又重新開始了,第二種方式分頁時進(jìn)行了計算,這樣會累計向下加,點三種放在cs代碼中
    2013-04-04

最新評論