ASPX:如何访问ASPX页面中的变量?
<form id="form1" runat="server">
<%
int a = 25;
%>
<asp:Label ID="Label1" runat="server"
Text='<%#a %>'></asp:Label>
</form>
代码后面:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataBind();
}
}
错误:
The name 'a' does not exist in the current context
你也许试试吧'<%=a %>' – pushpraj 2014-09-21 03:09:27
不行........ – 2014-09-21 03:11:05
不行。 'Text ='<%#a %>'>' - 您只需将字符串设置为文本。我想,你需要在代码中完成它:'<%Label1.Text = a>%'。 – 2014-09-21 04:13:21