1

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 this 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.

2 Answers 2

5

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” %>
Sign up to request clarification or add additional context in comments.

Comments

1

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() %>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.