开发者

acces static class properties from aspx page

I am on .aspx page and i want to take the width and height of a control from a static class where i have defined them as constans.

Is there any way to access that class directly from the aspx page?

I know that i can make a method like:

width="<%= getWidthSize() %>"

and inside the aspx.cs to define th开发者_运维问答is method to take the size from that static class.

But i am asking if this could be directly managed from the web aspx page...?

Thanks.


If they're in the same namespace, you can simply use

<%= ClassName.StaticMethod() %>

If the method you want to call is in another namespace, you need to either specify the full path

<%= Namespace.ClassName.StaticMethod() %>

or add an import page directive

<%@ Import namespace=”Namespace” %>


You could simply add an import directive and reference the static class propery directly.

http://msdn.microsoft.com/en-us/library/eb44kack.aspx

http://msdn.microsoft.com/en-us/library/79b3xss3(VS.80).aspx

E.g.

<%@ Import Namespace="SomeNamespace" %>

<%=SomeClass.SomeProperty.ToString() %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜