Connecting Tech Pros Worldwide Forums | Help | Site Map

Calling a public method in my code-behind class

Peter Morris [Droopy eyes software]
Guest
 
Posts: n/a
#1: Nov 18 '05
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


--
Pete
-------
Read/Write .NET articles
http://www.howtodothings.com/showart...ubcategory=132



Peter Morris [Droopy eyes software]
Guest
 
Posts: n/a
#2: Nov 18 '05

re: Calling a public method in my code-behind class


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

<%#= ShowNewsItem.Hello() %>


--
Pete
-------
Read/Write .NET articles
http://www.howtodothings.com/showart...ubcategory=132


Bharat Biyani
Guest
 
Posts: n/a
#3: Nov 18 '05

re: Calling a public method in my code-behind class


Remove the "#" symbol. That is used only when some Databinding is to be done.
Do it the old ASP way.

<%=FunctionName()%>
--
Bharat Biyani (bsb@orcim.com)
http://www.orcim.com



"Peter Morris [Droopy eyes software]" wrote:
[color=blue]
> Compiler Error Message: CS1525: Invalid expression term '='
>
> <%#= ShowNewsItem.Hello() %>
>
>
> --
> Pete
> -------
> Read/Write .NET articles
> http://www.howtodothings.com/showart...ubcategory=132
>
>
>[/color]
Peter Morris [Droopy eyes software]
Guest
 
Posts: n/a
#4: Nov 18 '05

re: Calling a public method in my code-behind class


Ahh, thanks, the # hadn't occurred to me :-)


--
Pete
-------
Read/Write .NET articles
http://www.howtodothings.com/showart...ubcategory=132


Peter Morris [Droopy eyes software]
Guest
 
Posts: n/a
#5: Nov 18 '05

re: Calling a public method in my code-behind class


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


--
Pete
-------
Read/Write .NET articles
http://www.howtodothings.com/showart...ubcategory=132


Guoqi Zheng
Guest
 
Posts: n/a
#6: Nov 18 '05

re: Calling a public method in my code-behind class


I think the correct one should be.

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


--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com

"Peter Morris [Droopy eyes software]" <pete@notformethanks_droopyeyes.com>
wrote in message news:uugdkGJeEHA.2440@tk2msftngp13.phx.gbl...[color=blue]
> 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[/color]
the[color=blue]
> following databound line?
>
> <%# DataBinder.Eval(Container.DataItem, "Title") %>
>
> If I use <%= then I cannot get access to Container, and if I use <%# then[/color]
I[color=blue]
> cannot use GetDisplayText
>
> Can you help?
>
> Thanks
>
>
> --
> Pete
> -------
> Read/Write .NET articles
> http://www.howtodothings.com/showart...ubcategory=132
>
>[/color]


Peter Morris [Droopy eyes software]
Guest
 
Posts: n/a
#7: Nov 18 '05

re: Calling a public method in my code-behind class


Hi

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



--
Pete
-------
Read/Write .NET articles
http://www.howtodothings.com/showart...ubcategory=132


Closed Thread