Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a function to format text C#

Status
Not open for further replies.

emozley

Technical User
Jan 14, 2003
769
GB
Hi,

In my .aspx page I have some code to display some data from a SQL query:

Code:
<asp:Label ID="EventDetailsLabel" runat="server" 
                Text='<%# Eval("EventDetails").ToString().Replace(Environment.NewLine,"<br />") %>' CssClass="upcomingevents_details" />

I figured this looked a little untidy so I decided to try and make a little function in my .cs file to do the formatting.

Code:
public string addLineBreaks(string eventDescription)
    {
        string formattedEventDescription = eventDescription.Replace(Environment.NewLine, "<br />");
        return formattedEventDescription;
    }

Please can you let me know how I call this function from my .aspx page - once I understand how to do that I am then going to make the function do a few other things to format the text just the way I want it.

Thanks very much

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top