Solved

How do you use public application method in markup

Posted on 2010-09-05
4
611 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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