zoukankan      html  css  js  c++  java
  • 在asp.net1.1中页面间传值

    好长时间没写blog了,今天无意中看到xlzhu兄的页面传值贴子,想起以前我所使用的方式,顺便唠叨着写上几句,算是自己复习或是送给有用的朋友吧

    对于这种传值问题,我以前用的是JS中的window.dialogArguments来实现.

    下面是MSDN中的example,可以参考一下,也可MSDN中搜一下"dalogArguments"

    1,
    <Page language="c#" Codebehind="WebForm3.aspx.cs" AutoEventWireup="false" Inherits="PageValue.WebForm3" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>WebForm3</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <SCRIPT>
    function fnLaunch()
    {
    var aForm;
    aForm = oForm.elements;
    var myObject = new Object();
    myObject.firstName = aForm.oFirstName.value;
    myObject.lastName = aForm.oLastName.value;
    // The object "myObject" is sent to the modal window.
    window.showModalDialog("modalDialogSource.htm", myObject, "dialogHeight:300px; dialogLeft:200px;");
    }
    </SCRIPT>


    </HEAD>
    <BODY ms_positioning="GridLayout">
    <BUTTON onclick="fnLaunch();" type="button">Launch The Window</BUTTON>
    <FORM ID="oForm">
    First Name: <INPUT TYPE="text" NAME="oFirstName" VALUE="Jane">
    <BR>
    Last Name: <INPUT TYPE="text" NAME="oLastName" VALUE="Smith">
    </FORM>
    </BODY>
    </HTML>
    2,modalDialogSource.htm
    <HTML>
    <HEAD>
    <SCRIPT>
    var oMyObject = window.dialogArguments;
    var sFirstName = oMyObject.firstName;
    var sLastName = oMyObject.lastName;
    </SCRIPT>
    <title>Untitled</title>
    </HEAD>
    <BODY STYLE="font-family: arial; font-size: 14pt; color: Snow;background-color: RosyBrown;">
    First Name:
    <SPAN STYLE="color:00ff7f">
    <SCRIPT>
    document.write(sFirstName);
    </SCRIPT>
    </SPAN>
    <BR>
    Last Name:
    <SPAN STYLE="color:00ff7f">
    <SCRIPT>
    document.write(sLastName);
    </SCRIPT>
    </SPAN>
    </BODY>
    </HTML>
    这个例子是用window.dialogArguments Property进行页面传值,从主页面到弹出的模式页进行传值,当然也可以换成从模式对话框页中选择值,然后在关闭对话框页面自动把值传到主页面来,其主体思想就是使用这个JS对象.

    当然这个对象也有一定的限制,下面是MSDN中的:

    dialogArguments Property


    Retrieves the variable or array of variables passed into the modal dialog window.

    Syntax

    [ vVariables = ] window.dialogArguments

    Possible Values

    vVariables String, numeric, object, or array value that specifies arguments.

    The property is read-only. The property has no default value.

    Remarks

    The dialogArguments property applies only to windows created using the showModalDialog and showModelessDialog methods.

    Standards Information

    There is no public standard that applies to this property.

  • 相关阅读:
    配置文件和脚本文件区别
    .sh
    瘋耔思维空间
    vi编辑器的三种模式
    在ubuntu系统荣品开发配套JDK安装
    如何查看自己运行ubuntu是32位还是64位
    志气
    高仿微信朋友圈
    Java OCR tesseract 图像智能字符识别技术 Java代码实现
    构建基于Javascript的移动CMS——加入滑动
  • 原文地址:https://www.cnblogs.com/linfuguo/p/229851.html
Copyright © 2011-2022 走看看