代码如下:
<%@ 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文件
<%@ 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文件
行 24: <body>
行 25: <form id="Form1" method="post" runat="server">
行 26: <%=yonghu%>
行 27: </form>
行 28:
把
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的值。
這個去掉。
我想你是想從webform1中傳一個yonghu變量過來這邊得到吧?
要作为一个member加上
<%@ private string yonghu ; %>
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>
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。
<%@ 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>
例如:aabb.aspx?username=123456