ret=window.showModalDialog("b.aspx?y="+Server.UrlEncode("2003年"), null,"dialogHeight: 550px; dialogWidth: 700px;");
在另一张页
string y=Server.UrlDecode("y");
只时y="2003年"

解决方案 »

  1.   

    string s="<script language='javascript'>var ret=new Array(0);ret=window.showModalDialog('b.aspx?y=";
    s=s+System.Web.HttpUtility.UrlEncode("2003"+this.Server.HtmlEncode(aa);//);
    s=s+"', null,'dialogHeight: 550px; dialogWidth: 700px;');window.Form1.all.TextBox1.value=ret[0];</script>";
    Response.Write(s);
      

  2.   

    string s="<script language='javascript'>var ret=new Array(0);ret=window.showModalDialog('b.aspx?y=";
    s=s+System.Web.HttpUtility.UrlEncode("2003"+this.Server.UrlEncode(aa));
    s=s+"', null,'dialogHeight: 550px; dialogWidth: 700px;');window.Form1.all.TextBox1.value=ret[0];</script>";
    Response.Write(s);
      

  3.   

    谢谢cenxaoi(毅) 。不是另一页调用Request.QueryString[0]的问题,而是在客户端运行的javascript不认Server.UrlEncode这个函数。
      

  4.   

    谢谢dongchuanlu(匡奇)。不是System.Web.HttpUtility.UrlEncode("2003年")有问题,而是window.Form1.all.TextBox1.value=ret[0]无法得到正确的返回值TextBox1.Text。
      

  5.   

    把document 的charset改为gb2312
    或增加在aspx页增加</title>后面
    <META http-equiv="Content-Type" content="text/html; charset=gb2312">
      

  6.   


    Response.Write(s);
    改为
    RegisterStartupScript("a",s);
    Response.Write(s)输出的内容在<html>之前 这是还没有<input id="TextBox1">,即浏览器还没找到TextBox1对象
    而RegisterStartupScript输出的语句是在</From>之前。此时IE已经认出了"TextBox1"的对象。另外window.Form1.all.TextBox1.value=ret[0];
    改为document.all.TextBox1.value=ret[0];
    你不能写Form1 因为客户端脚本语句还在<Form></Form>之间,浏览器还没找到Form1的完整对象,此时不要使用Form1。
      

  7.   

    var ret=new Array(0);
    var var1= encodeURIComponent("2003年");
    ret=window.showModalDialog("b.aspx?y="+var1+", null,"dialogHeight: 550px; dialogWidth: 700px;");
    window.Form1.all.TextBox1.value=ret[0]; //用這個encodeURIComponent一定可以的
      

  8.   

    谢谢 cenxaoi(毅)和 pengweihua(pwh)。pengweihua(pwh)的方法既简单又漂亮,是我最初想用的方法。cenxaoi(毅)的方法正好可以帮助我解决相关的更复杂的问题。我看见其他有些人的贴子中提到给分的事。我这是刚刚学习上网请教问题,不知如何给分,也就不知道如何进一步感谢二位才好。