且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何调用code变量后面的aspx页面

更新时间:2023-11-12 13:18:40

字段必须声明公共从ASPX标记正确的知名度。在任何情况下,你可以声明一个属性:

The field must be declared public for proper visibility from the ASPX markup. In any case, you could declare a property:


private string clients;
public string Clients { get { return clients; } }

更新:它也可以被声明为保护,如下面的注释中规定

UPDATE: It can also be declared as protected, as stated in the comments below.

然后,把它在ASPX端:

Then, to call it on the ASPX side:

<%=客户端%>

<%=Clients%>

请注意,如果你把它放在一台服务器标记属性这是不行的。例如:

Note that this won't work if you place it on a server tag attribute. For example:

&LT; ASP:标签=服务器文本=&LT;%=客户端%>/>

<asp:Label runat="server" Text="<%=Clients%>" />

这是无效的。这是:

&LT; D​​IV>&LT;%=客户端%>&LT; / DIV>

<div><%=Clients%></div>