3

I have a function written in a class in C#. This function returns the path for src attribute of img tag. Now I want to use this in on page this way:

<img src=<%=myclass.GetImageUrl('imagename')%> >

Is it posible to do so in ASP.NET on aspx pages?

Or is there any other waw to call function on a aspx page?

0

1 Answer 1

5

Your code will work fine, as long is the class is public and the function is public static, and as long as you've imported the namespace in an <%@ Import %> directive.

Sign up to request clarification or add additional context in comments.

8 Comments

@Slaks and you have a reference to the namespace
Why does the method have to be static? The page aka this is in scope.
@leppie: The method is in a different class.
@SLaks: Perhaps myClass is a protected member of the page.
@leppie I think that it's quite obvious that myClass is a class and not an object, isn't it? if it really is an object, he should consider naming it better
|

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.