主窗体如:WEBFORM1.ASPX
子窗体如:DEMO1.HTM
本人在单击主窗体中的BUTTON按钮(HTML)后,弹出一个子窗体(作为一个DIALOG模式窗体).子窗体上有一些文本框
编号:<input type = "Text" name = "txtUserCode" id = "txtUserCode" />
用户名:<input type = "Text" name = "txtUserName" id = "txtUserName" />
<input type = "button" name = "btnSave" value="新增" />
请问:如问将html窗体中的值传到ASPX窗体中去?或者能够通过javascript值接能够调用方法,把值写到数据库中。
希望有代码解释。谢谢,小弟不胜感激!

解决方案 »

  1.   

    小弟使用的语言:C#,平台:VS2003。
      

  2.   

    弹出子窗体为模式窗体的话,用returnvalue返回即可
    在子窗体的提交按钮写js的click方法
    按你给出的控件
    function addUser(){
    window.returnValue=document.getElementById("txtUserCode").value+"|"+document.getElementById("txtUserName").value;
    window.close();
    }在父窗体得值的js写在
    弹出窗体的按钮的click事件里var userInfo=window.showModalDialog("DEMO1.HTM",参数...);
    编号=userInfo.split("|")[0];
    用户名=userInfo.split("|")[1];
      

  3.   

    除了2楼的方法,还有另一种方法:
    演示代码:
    在父窗口
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %><!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">
        <title>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <script type="text/javascript">
        function setValue(sValue){
            document.getElementById("txt1").value = sValue;
        }
        function openForm(){
        window.open("default6.aspx");
        }
        </script>
        <div>
        <input id="txt1" type="text" /><input id="Button1" type="button" value="button" onclick="setValue('clicked')" />
        <br />
            <input id="Button2" type="button" value="button" onclick="openForm()" />
        </div>
        </form>
    </body>
    </html>在子窗口
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default6.aspx.cs" Inherits="Default6" %><!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">
        <title>无标题页</title>
    </head>
    <body>
    <script type="text/javascript">
    function setPrt(){
        opener.document.getElementById("txt1").value="by child form";
    }
    </script>
        <form id="form1" runat="server">
        <div>
            <input id="Button1" type="button" value="button" onclick="setPrt()" />
        </div>
        </form>
    </body>
    </html>
      

  4.   

    1. http://www.wangyuit.com/boke/more.asp?name=johnson&id=199
    2. http://www.wangyuit.com/boke/more.asp?name=johnson&id=71
      

  5.   

    子窗体代码
    <form name="mForm" action="父页" method="post">
        编号: <input   type="Text"   name="txtUserCode"   id="txtUserCode"/> 
        用户名: <input   type="Text"   name="txtUserName"   id="txtUserName"   /> 
        <input   type   =   "submit"   name="btnSave"   value="新增"   /> 
    </form>
    在父窗体的Page_Load事件里写
    变量1=Request.Form["txtUserCode"].ToString();
    变量2=Reuuest.Form["txtUserName"].ToString();
    //存储数据
      

  6.   

    在 From2
    public  string aa = "":
     Form1 調用 
      From2 frm2 = new From2();
      string bb = frm2.aa;
    //纯属捣乱
    // 看贴没事干,郁闷着呢。