Calling a public method in my code-behind class

  • Thread starter Thread starter Peter Morris [Droopy eyes software]
  • Start date Start date
P

Peter Morris [Droopy eyes software]

Hi all

In my codebehind class I have the following

public String GetDisplayText(String originalText)

It replaces < with &lt; etc

What I need to know is, in my ASPX file how do I call this method? I tried

<% GetDisplayText("<<<") %>

but the compiler fails, saying the GetDisplayText could not be found. I
also tried making this a static method and calling
MyPageClassName.GetDisplayText but received the same error.

I don't want to place the method code inside the ASPX, so, how do I call a
public method which exists within my codebehind?

Thanks
 
Compiler Error Message: CS1525: Invalid expression term '='

<%#= ShowNewsItem.Hello() %>
 
Remove the "#" symbol. That is used only when some Databinding is to be done.
Do it the old ASP way.

<%=FunctionName()%>
 
I am trying to convert DB text such as < and > to html text such as &lt;
&gt; etc.

I created a method

public String GetDisplayText(String originalText)

which replaces all of the necessary characters, but how would I replace the
following databound line?

<%# DataBinder.Eval(Container.DataItem, "Title") %>

If I use <%= then I cannot get access to Container, and if I use <%# then I
cannot use GetDisplayText

Can you help?

Thanks
 
Hi

That did it, but I had to add .ToString() at the end, thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top