Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!')

}

}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report