?
Solved

How do you use public application method in markup

Posted on 2010-09-05
4
Medium Priority
?
620 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 1000 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

770 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