473,395 Members | 1,616 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Calling a public method in my code-behind class

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
Nov 18 '05 #1
6 1166
Compiler Error Message: CS1525: Invalid expression term '='

<%#= ShowNewsItem.Hello() %>
--
Pete
-------
Read/Write .NET articles
http://www.howtodothings.com/showart...ubcategory=132
Nov 18 '05 #2
Remove the "#" symbol. That is used only when some Databinding is to be done.
Do it the old ASP way.

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

"Peter Morris [Droopy eyes software]" wrote:
Compiler Error Message: CS1525: Invalid expression term '='

<%#= ShowNewsItem.Hello() %>
--
Pete
-------
Read/Write .NET articles
http://www.howtodothings.com/showart...ubcategory=132

Nov 18 '05 #3
Ahh, thanks, the # hadn't occurred to me :-)
--
Pete
-------
Read/Write .NET articles
http://www.howtodothings.com/showart...ubcategory=132
Nov 18 '05 #4
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
Nov 18 '05 #5
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:uu**************@tk2msftngp13.phx.gbl...
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

Nov 18 '05 #6
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
Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: neptune | last post by:
I have limited knowledge of VBA, but I've learned a lot here. I can't figure out how to pass 2 parameters in a sub? I call PassDate and pass 1 date. Public Sub PassDate() Calculate...
5
by: Chua Wen Ching | last post by:
I had use fxcop to check my code. I had 1 confusion here. I would normally call a method by this way in my IAnimal: Example: public void CallFuncA(ushort port); But fxcop says i need to...
0
by: Carlitos | last post by:
Hi there, I apologize if it is not the right forum to post this question, but it has to do with C#, HTML and javascript altogether. I programmed a windows form custom control in C# which...
4
by: ST | last post by:
From Form1 I call a public sub in a module. The sub writes on Form1. Problem: the call creates a new Form1 and writes on it, instead of writing on the one already shown Form1. I have tried to...
7
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type...
7
by: Stu | last post by:
Hi, I have a web service which returns a record set and works well integrated with an asp dot net page. However if I decided to develop a unix app will i be able to read the dataset as it is...
3
by: Jason | last post by:
I have an ASP.NET application in which I would like to call my button click event (imgSubmitSearch_Click) on the page load if certain criteria are met. Is this possible? What is the correct...
2
by: kbutterly | last post by:
Good afternoon, I have what appears to be a caching issue, but i'm a bit of a newbie at http headers so it may be something else. I have a small asp.net 2.0 application that is called to serve...
1
by: DevNll2002 | last post by:
Can it be done? ( This is a related issue to my recent post... http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/browse_thread/thread/a229a66642bedfaf/870614ae257ae699...
5
by: bizt | last post by:
Hi, Below I have a simple object / function thing (still getting head round these) declaration: function MyObject() { this.alertMe = function() { alert('hello'); }; this.alertMeAgain() {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.