Obtain the Layer Pop-up Layer return value in asp.net
1. click the button in MainPage. aspx to use the Layer Pop-up Layer. The Code is as follows:
<% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "MainPage. aspx. cs" Inherits = "demo. MainPage" %>
<Script src = ".. /Scripts/Jquery-1.8.0.min.js "> </script> <script src = ".. /Scripts/layer. js "> </script> <script type =" text/javascript "> $ (function () {layer. config ({extend: ['skin/espresso/style.css '], // load new skin: 'layer-ext-espresso' // once set, this topic is used for all bullet layer styles. }) ;}); // Function popUp () {var UnitCode = "110000"; layer. open ({title: ['advanced query'], type: 2, content: "SubPage. aspx? UnitCode = "+ UnitCode, area: ['500px ', '20px'], shade: 0.3, btn: ['OK', 'close'], yes: function (index) {var res = window ["layui-layer-iframe" + index]. saveFunc (); if (res! = False) {$ ("# hidSelectUnit "). val (res. selectUnit); $ ("# hidCompareDate "). val (res. compareDate); $ ("# hidCompareTips "). val (res. compareTips); $ ("# form1 "). submit () ;}}) ;}</script>
Protected void Page_Load (object sender, EventArgs e) {if (! String. IsNullOrEmpty (Request. QueryString ["FormSubmit"]) {this. divMsg. InnerHtml = "unit encoding:" + hidSelectUnit. Value +"
Comparison Date: "+ hidCompareDate. Value. Split (',') [0] +" | "+ hidCompareDate. Value. Split (',') [1] +"
Comparison tip: "+ hidCompareTips. Value. Split (',') [0] +" | "+ hidCompareTips. Value. Split (',') [1];}
Key code:
Layer. open ({
Title: ['advanced query'],
Type: 2,
Content: "SubPage. aspx? UnitCode = "+ UnitCode,
Area: ['500px ', '20px'],
Shade: 0.3,
Btn: ['OK', 'close'],
Yes: function (index ){
Var res = window ["layui-layer-iframe" + index]. saveFunc ();
If (res! = False ){
$ ("# HidSelectUnit"). val (res. SelectUnit );
$ ("# HidCompareDate"). val (res. CompareDate );
$ ("# HidCompareTips"). val (res. CompareTips );
$ ("# Form1"). submit ();
}
}
});
2. SubPage. aspx is the content area of the pop-up box. The Code is as follows:
<% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "SubPage. aspx. cs" Inherits = "demo. SubPage" %>
Pop-up page<Script src = ".. /Scripts/Jquery-1.8.0.min.js "> </script> <script src = ".. /Scripts/layer. js "> </script> <script type =" text/javascript "> $ (function () {layer. config ({extend: ['skin/espresso/style.css '], // load new skin: 'layer-ext-espresso' // once set, this topic is used for all bullet layer styles. }) ;}); Function saveFunc () {var selectedUnit =$ ("# unitcode "). val (); var compareDate = new Array (); compareDate [0] = "2015-12-01"; compareDate [1] = "2015-12-23"; var compareTips = new Array (); compareTips [0] = "Hefei"; compareTips [1] = "lu'an"; var returnJson = {"SelectUnit": selectedUnit, "CompareDate": compareDate, "CompareTips ": compareTips} return returnJson;} </script>
3. shows the effect:
Confirm and accept the information and other information entered at the pop-up layer, as shown in: