'Upload.aspx?param1='+$("#txtbanbenhao").val()+'&param2='+$("#txtgonghao").val()为什么在获取不到param2的值,只能获取param1的值啊。

解决方案 »

  1.   

    $("#txtgonghao").val() 
    有值吗 ?
    你这样 应该是没问题的 。
      

  2.   


    有值啊,我也纳闷呢,同样的写法,为什么param1能取到值,param2却不行。
      

  3.   

    alert($("#txtgonghao").val());
    如果他有值那么你就看一下php的部分param2的取值部分.
    或者firebug看一下传递状况
      

  4.   

    以下是我的代码:
    Default.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_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">
        <title></title>
        <link rel="Stylesheet" href="js/uploadify.css" /> 
        <script type="text/javascript" src="js/jquery.min.js"></script> 
        <script type="text/javascript" src="js/swfobject.js"></script> 
        <script type="text/javascript" src="js/jquery.uploadify.min.js"></script> 
        <script type="text/javascript"> 
        
        $(document).ready(function() { 
        $("#uploadify").uploadify({ 
        'uploader': 'js/uploadify.swf', 
        'script': 'Upload.aspx?param2='+$("#txtbanbenhao").val()+'&param1='+$("#txtgonghao").val(), 
        'cancelImg': 'js/cancel.png', 
        'folder': 'upload', 
        'queueID': 'fileQueue', 
        'auto': false, 
        'multi': true, 
        }); 
        }); 
        </script>
    </head>
    <body>
        <form id="form1" runat="server" > 
            <input type="file" name="uploadify" id="uploadify" /> 
            <a href="javascript:$('#uploadify').uploadifyUpload()">上传</a>| <a href="javascript:$('#uploadify').uploadifyClearQueue()"> 取消上传</a> 
            
            <div id="fileQueue">
                <asp:TextBox ID="txtgonghao" runat="server"></asp:TextBox>
                 <asp:TextBox ID="txtbanbenhao" runat="server"></asp:TextBox>
            </div> 
        </form>
    </body>
    </html>
    Upload.aspx页面
    <asp:TextBox ID="txtgonghao" runat="server"></asp:TextBox>
            <asp:TextBox ID="txtbanbenhao" runat="server"></asp:TextBox>
    Upload.aspx.cs 代码
    using System; 
    using System.Data; 
    using System.Configuration; 
    using System.Collections; 
    using System.Web; 
    using System.Web.Security; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using System.Web.UI.WebControls.WebParts; 
    using System.Web.UI.HtmlControls; 
    using System.IO; public partial class Upload : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string param1 = Request.QueryString["param1"];
            string param2 = Request.QueryString["param2"];
            this.txtgonghao.Text = param1;
            this.txtbanbenhao.Text = param2;
          
            string path = Server.MapPath("files/");
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            HttpFileCollection files = Request.Files;
            string fileName = string.Empty;
            for (int i = 0; i < files.Count; i++)
            {
                fileName = Path.GetFileName(files[i].FileName).ToLower();
                files[i].SaveAs(path + fileName);
            }
        }
    }
      

  5.   


    alert($("#txtgonghao").val());有值。
    firebug 这是什么
      

  6.   

    firebug是火狐的一个插件 用来调试js很好用.console.log("ddd")乃火狐神器,避免了烦人的alert
      

  7.   

    你在upload.aspx.cs 里面 打印 Response.Write(Request.QueryString.ToString()); 看有没有传过来,如果没有就是插件的问题
      

  8.   

    uploadifyID=uploadify&pagepath=/WebSite2/&script=Upload.aspx?param1=1&param2=2&folder=upload&width=110&height=30&wmode=opaque&method=POST&queueSizeLimit=999&simUploadLimit=1&multi=true&fileDataName=Filedata&queueID=fileQueue我用firebug调试的时候发现param1=1 和 param2=2 的值是传过来了,但是是不是写法有问题啊。Upload.aspx?param1=1&param2=2 是不是因为这么写的时候把param2的值没有当成参数传过去。
      

  9.   

    "&" 在JavaScript解析为变量连接符,所以服务器端接收数据时&符号以后的数据都会丢失。是不是这个原因造成我的param2的参数没有传递过来。如果是这种情况,该如何解决。
      

  10.   

    试一下用scriptData传值
    'scriptData'  : ({'var_name': 'this_var_value'}),
      

  11.   


    这种传值方式我不会,不过我知道是什么原因造成param2的值传不过去了,是因为&造成的,丢失参数,我解析了一下变量符& ,解决方法http://hi.baidu.com/aboc/blog/item/1bc73ac7207c58d7d1006031.html
      

  12.   

    我发现了是因为在传值的时候&连接符没有解析,解决方法 replace(/\&/g, "%26")