Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the return value of asp.net pop-up window

Shulou Source: shulou.com Published: 2022-06-03 07:45:17 10月04日 Update

This article mainly explains "how to achieve the asp.net pop-up window return value", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to achieve the asp.net pop-up window return value" bar!

Page.aspx:

The copy code is as follows:

Untitled page

...

Function Pop ()

... {

Var result=showModalDialog ('downs.aspx','subpage','dialogWidth:400px;dialogHeight:300px;center:yes;help:no;resizable:no;status:no'); / / Open the modal sub-form and get the return value

Document.getElementById ("txt_id") .value=result.split ("'") [0]; / / return values are assigned to the relevant text boxes respectively

Document.getElementById ("txt_name"). Value=result.split ("'") [1]

Document.getElementById ("txt_pwd"). Value=result.split ("") [2]

}

Downs.aspx: pop-up pa

The copy code is as follows:

Untitled page

...

Function cc (infor_id,infor_name,infor_psw) / / parameters are id,name and password, respectively

... {

Window.returnValue= infor_id+ "'" + infor_name+ "" + infor_psw; / / return value

Window.close ()

}

Downs.cs: the background code of the popup page:

The copy code is as follows:

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 + "'))

}

}

}

The second way:

ReturnValue is a property of the window object of html in javascript. The purpose is to return the window value when using the

The window.showModalDialog function opens an IE mode window (you know, the mode window cannot operate the parent window after it is opened, but can only be operated when the mode window is closed). The following example is used to return the value of the window:

The copy code is as follows:

/ / father.html

Function showmodal () {

Var ret = window.showModalDialog ("child.htm", null, "dialogWidth:350px;dialogHeight:350px;help:no;status:no")

If (ret) {alert ('child window returns true!')

} else {

Alert ('child window returns false!')

}

}

Tags: Code function pattern facet learning function content that is situation server title appearance form page service so that that is to say an example Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker vpn Redmi Microsoft OPPO Reno