Obtain the Layer Pop-up Layer return value in asp.net

Source: Internet
Author: User

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:





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.