C# 从弹出页面得到返回值

 
Default.aspx
<%@ Page Language= "C#" AutoEventWireup= "true" CodeBehind= "Default.aspx.cs" Inherits= "WebAppDialog._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

  <script type="text/javascript" language="javascript">
    function pop() {
      var arr = showModalDialog("pop.html", "", "dialogWidth:50em; dialogHeight:20em; status:0");
      if (arr != null) {
        javascript: document.forms[0]['TextBox1'].value = arr;
      }
    }
  </script>

  <title></title>
</head>
<body>
  <form id="form1" runat="server">
  <table>
    <tr>
      <td align="right">
        Long-distance code:
      </td>
      <td align="center">
        <asp:TextBox ID="TextBox1" runat="server" Enabled="False"></asp:TextBox>
      </td>
      <td align="left">
        <input type="button" id="button1" value="Select City" onclick="pop()" />
      </td>
    </tr>
  </table>
  </form>
</body>
</html>
 
pop.html:
<head>

  <script type= "text/javascript" language= "javascript">
    function check(s) {
      window.returnValue = s;
      window.opener = null;
      window.close();
    }
  </script>

  <title>showmodaldialog_pop.html</title>
</head>
<body>
  <table bgcolor= "#000000" border= "0" cellpadding= "1" cellspacing= "1" width= "400">
    <tr>
      <td align= "middle" bgcolor= "#ffcc33" height= "30" width= "15%">
        <p>
          City</p>
      </td>
      <td align= "middle" bgcolor= "#ffcc33" height= "30" width= "35%">
        Code
      </td>
      <td align= "middle" bgcolor= "#ffcc33" height= "30" width= "15%">
        City
      </td>
      <td align= "middle" bgcolor= "#ffcc33" height= "30" width= "35%">
        Code
      </td>
    </tr>
    <tr align= "middle" bgcolor= "#ffffff">
      <td height= "30" width= "35%">
        Bei Jing<a name= "beijing"></a>
      </td>
      <td height= "30" width= "15%">
        <a href= "#" onclick= "check('010')">010</a>
      </td>
      <td height= "30" width= "35%">
        Shang Hai
      </td>
      <td height= "30" width= "15%">
        <a href= "#" onclick= "check('021')">021</a>
      </td>
    </tr>
    <tr align= "middle" bgcolor= "#ffffff">
      <td height= "30" width= "35%">
        Tian Jin<a name= "tianjin"></a>
      </td>
      <td height= "30" width= "15%">
        <a href= "#" onclick= "check('022')">022</a>
      </td>
      <td height= "30" width= "35%">
        Chong Qing
      </td>
      <td height= "30" width= "15%">
        <a href= "#" onclick= "check('023')">023</a>
      </td>
    </tr>
  </table>
</body>

你可能感兴趣的:(返回值,C#,职场,休闲)