关于从另外一个页面请求传值问题

版权声明:Till good is better, but better best !My trying hard will go on!Please wait and see! https://blog.csdn.net/u012761373/article/details/42238875

以前不知道什么时候写的代码,现在翻出来看到了,或许以后会用到吧,记录下来珍藏;

原理:通过双击选择,调用js打开另外一个页面,通过另外一个页面输入所谓的值(x1),传到当前页面;


ShowModalDialogDefault.aspx页面代码:

前台代码:

<script src="js/jquery-1.9.1.min.js" type="text/javascript"></script>
   <pre class="cpp" name="code"><div>
        <table>
            <tr>
                <th>传递过来的值为:</th>
                <td colspan="2">
                    <%--示例一--%>
                    <asp:Label ID="lblAccept1" runat="server" Text="Label"></asp:Label>
                    <asp:TextBox ID="lblAccept" runat="server"></asp:TextBox>
                   <a href="javascript:void(0);" onclick="sel_Select();">选择</a>
                </td>
		<%--示例二--%>
                <td>
                    <asp:TextBox ID="txtAccept" runat="server"></asp:TextBox>
                </td>
                <td>
                    <input id="btnSelect" type="button" value="选择" />
                </td>
            </tr>
        </table>
    </div>

 
 
js代码:
$("#btnSelect").click(function() {
            var url = "ShowModalDialogReturnValue.aspx?IsShowOk=true";
            var call_result = showMyDialog(url, 500, 700);
            if (call_result != null) {
                $("#txtAccept").val(call_result);
            }
        })
        function sel_Select() {
            var url = "ShowModalDialogReturnValue.aspx?IsShowOk=true";
            var call_result = showMyDialog(url, 500, 700);
            if (call_result != null) {
                $("#lblAccept1").html(call_result);
                document.getElementById("lblAccept").value = call_result;
//                $("#lblAccept").val(call_result);
            }
        }
        function showMyDialog(url, h, w) {
            return window.showModalDialog(url, window, "dialogHeight:" + h + "px;dialogWidth:" + w + "px;center:yes;status:no;help:no;scroll:no;");
        }


前台代码:

<div>
        <tables
            <tr>
                <th>请输入要传递的值:</th>
                <td>
                    <asp:TextBox ID="txtSend" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="button" value="确 定(s)" accesskey="(s)" name="makesure" onclick="ok();" />
                </td>
                
            </tr>
        </table>
    </div>

如果传递的值是相对比较大(DataTable,DataSet里的一行、几行数据),你可以选择传递所选的行值,然后再父页面执行相关代码程序,就可以了

附件js。



猜你喜欢

转载自blog.csdn.net/u012761373/article/details/42238875