代码如下:
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" Debug="true"%>
<%@ Import Namespace="System"%>
<%@ Import Namespace="System.Web.UI.WebControls"%>
<%@ Import Namespace="System.Web.UI.HtmlControls"%>
<%@ Import Namespace="System.Web.Security " %>
<%@ Import Namespace="System.Web.Security " %>
<%@ Import Namespace="System.Web.Security " %><script runat="server"> 
protected void Page_Load(Object Src, EventArgs E) 
 {
  string yonghu = string.Empty;
  yonghu=Request.QueryString["username"]; 
 }
</script><form id="Form1" method="post" runat="server">
<%=yonghu%>
</form>错误提示如下:编译器错误信息: CS0103: 名称“yonghu”在类或命名空间“ASP.aabb_aspx”中不存在
这是什么原因呢?我代码写在ASPX页面里,无CS文件

解决方案 »

  1.   

    源错误:
    行 24: <body>
    行 25: <form id="Form1" method="post" runat="server">
    行 26: <%=yonghu%>
    行 27: </form>
    行 28: 
     
      

  2.   

    yonghu在Page_Load方法里,当然在类或命名空间“ASP.aabb_aspx”中不存在了。

    protected void Page_Load(Object Src, EventArgs E) 
     {
      string yonghu = string.Empty;
      yonghu=Request.QueryString["username"]; 
     }
    改成
    string yonghu = string.Empty;
    yonghu=Request.QueryString["username"]; 
    protected void Page_Load(Object Src, EventArgs E) 
     {
     }
    或者把
    string yonghu = string.Empty;
    yonghu=Request.QueryString["username"]; 
    写在一个方法里面,然后调用方法来返回yonghu的值。
      

  3.   

    行 26: <%=yonghu%>
    這個去掉。
    我想你是想從webform1中傳一個yonghu變量過來這邊得到吧?
      

  4.   

    yonghu是Page_Load private的,页面上看不到
    要作为一个member加上
    <%@ private string yonghu ; %>
      

  5.   

    我是要取得另一个网页传过来的值赋给FLASH。。我先试试jxufewbt的方法。
      

  6.   

    <script runat="server"> 
    string yonghu;
    protected void Page_Load(Object Src, EventArgs E) 
     {
      yonghu = string.Empty;
      yonghu=Request.QueryString["username"]; 
     }
    </script><form id="Form1" method="post" runat="server">
    <%=yonghu%>
    </form>
      

  7.   

    <script runat="server"> 
      string yonghu = string.Empty;
      yonghu=Request.QueryString["username"]; 
    protected void Page_Load(Object Src, EventArgs E) 
     { }
    </script>
    这样之后却提示:
    编译器错误信息: CS1519: 类、结构或接口成员声明中的标记“=”无效源错误: 行 9:  <script runat="server"> 
    行 10:   string yonghu = string.Empty;
    行 11:   yonghu=Request.QueryString["username"]; 
    行 12: protected void Page_Load(Object Src, EventArgs E) 
    行 13:  {
     源文件: F:\视频售楼\Video_sell\aabb.aspx    行: 11 能贴个详细的代码吗?刚学.net。
      

  8.   

    试试:
    <%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" Debug="true"%>
    <%@ Import Namespace="System"%>
    <%@ Import Namespace="System.Web.UI.WebControls"%>
    <%@ Import Namespace="System.Web.UI.HtmlControls"%>
    <%@ Import Namespace="System.Web.Security " %>
    <%@ Import Namespace="System.Web.Security " %>
    <%@ Import Namespace="System.Web.Security " %><script runat="server"> 
    protected void Page_Load(Object Src, EventArgs E) 
     {
     }
    public string GetYonghu()
    {
      string yonghu = string.Empty;
      yonghu=Request.QueryString["username"]; 
      return yonghu;
    }
    </script><form id="Form1" method="post" runat="server">
    <%GetYonghu();%>
    </form>
      

  9.   

    swordragon(古道热肠) 方法虽没错,但却得到的是空值。
    例如:aabb.aspx?username=123456