Solved

How do you use public application method in markup

Posted on 2010-09-05
4
618 Views
Last Modified: 2013-11-07
I have an application class method defined as follows:

Public Class AppHelper

    Public Shared Function MyFunction(ByVal sInput As String)
        Return "MyFunction." & sInput
    End Function

End Class

Open in new window


In my markup I want to do something like this:
    <div>
        <%# AppHelper.MyFunction(DataBinder.Eval(Container.DataItem, "MyField"))  %>
    </div>

Open in new window


But building the application says AppHelper is not defined. If I change the call to just MyFunction(...), it says MyFunction is not defined. I can get around this by moving the function to the base page class but is there any way to call it directly from the AppHelper class?

Thanks in advance.
0
Comment
Question by:ZekeLA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:richard_hughes
ID: 33607412
Hello ZekeLA

Try this:

Thanks,

Richard Hughes
<div> 
        <% AppHelper.MyFunction(DataBinder.Eval(Container.DataItem, "MyField"))  %> 
    </div>

Open in new window

0
 
LVL 1

Author Comment

by:ZekeLA
ID: 33607595
Removing the # symbol didn't work. It still gives the same problem. Also, this function is actually inside another function which I think requires the # symbol. When I removed the symbol, that part of the markup didn't display.
0
 
LVL 9

Assisted Solution

by:richard_hughes
richard_hughes earned 250 total points
ID: 33607601
Hmm, i'm not sure of any other way using markup. You could try wrapping the call to AppHelper in a method in your page class, or perhaps in your page's base class. Then call that method in your markup. That would work.
Thanks
0
 
LVL 1

Accepted Solution

by:
ZekeLA earned 0 total points
ID: 33607649
That's what I've currently got it place. I have the method defined in a class and I then call that from a method with the same name in my page's base class. I was just wondering if there was a way not to have to create the proxy method.

I want to wait a day or two to see if anyone else has a way to bypass the proxy method before I close this out.
0

Featured Post

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question