Solved

How do you use public application method in markup

Posted on 2010-09-05
4
578 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
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:richard_hughes
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now