473,385 Members | 1,387 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,385 software developers and data experts.

Carriage Returns

In ASP using VBScript to replace Chr(13) or Chr(10) with a <br> tag I would
use the Replace method so that I can catch carriage returns from a memo field
in MS Access or a Text field in MS SQL Server. For instance
<%=Replace(rs.Fields.Item("column").Value),Chr(13) ,"<br />")%>. I am, now,
migrating to ASP.NET 1.1 and am using C# as the primary programming language.
In one of my contracts I have a database table with a field that must be a
text field in SQL Server that must hold carriage returns which does not
convert to <br> when I serve up the data field. The table in the database
that holds the text field is a child table of another table. I need to be
able to convert a new line "\n" to the HTML equivalent "<br />"
programatically. Nothing I have done has worked. So far I have tried:

<asp:Repeater ID="SomeDataSource" Runat="Server">
<ItemTemplate>
<%# Databinder.Eval(Container.DataItem, "SomeField").Replace("\n",
"<br>")%>
</ItemTemplate>
</asp:Repeater>
But that does not work. I keep on getting an error that says 'Replace'
associated with the object 'Whateverpage.aspx'
or I get an error that states something to the effect that a method was
expected but got a property-- something like that error-- the meaning is the
same. Whatever the case I think I'm getting something wrong.

If anyone can tell me where I am going wrong I would greatly appreciate it.

Thank you,

Sam-
Nov 18 '05 #1
1 2650
Hello I am Sam" I am,

You probably need to cast from the object to a string...

try something like this (untested): <%# ((string)DataBinder.Eval(Container.DataItem, "SomeField")).Replace("\n", "<br>"); %>

--
Matt Berther
http://www.mattberther.com
In ASP using VBScript to replace Chr(13) or Chr(10) with a <br> tag I
would
use the Replace method so that I can catch carriage returns from a
memo field
in MS Access or a Text field in MS SQL Server. For instance
<%=Replace(rs.Fields.Item("column").Value),Chr(13) ,"<br />")%>. I am,
now,
migrating to ASP.NET 1.1 and am using C# as the primary programming
language.
In one of my contracts I have a database table with a field that must
be a
text field in SQL Server that must hold carriage returns which does
not
convert to <br> when I serve up the data field. The table in the
database that holds the text field is a child table of another table.
I need to be able to convert a new line "\n" to the HTML equivalent
"<br />" programatically. Nothing I have done has worked. So far I
have tried:

<asp:Repeater ID="SomeDataSource" Runat="Server">
<ItemTemplate>
<%# Databinder.Eval(Container.DataItem,
"SomeField").Replace("\n",
"<br>")%>
</ItemTemplate>
</asp:Repeater>
But that does not work. I keep on getting an error that says
'Replace'
associated with the object 'Whateverpage.aspx'
or I get an error that states something to the effect that a method
was
expected but got a property-- something like that error-- the meaning
is the
same. Whatever the case I think I'm getting something wrong.
If anyone can tell me where I am going wrong I would greatly
appreciate it.

Thank you,

Sam-


Nov 18 '05 #2

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

Similar topics

4
by: Les Juby | last post by:
Can someone please help with a suggestion as to how I can keep the formatting (carriage returns) that the user enters into a memo field and then display that later. I figured I might be able to...
2
by: Andrew Chanter | last post by:
I have a VBA function that returns a string including "vbcr" (VB Carriage Return) to seperate a list into multiple rows, eg Item1 & vbcr & Item2 & vbcr & Item3 This works as planned in the...
2
by: eagleofjade | last post by:
I am trying to import data from a Word document into an Access table with VBA. The Word document is a form which has various fields. One of the fields is a field for notes. In some cases, this...
12
by: Nimmy | last post by:
Hi, I have a data file and I want to remove Carriage returns. Any one has any C code/program which does this? I am working on Windows XP machine.....I don't have access to UNIX machine. But I...
2
by: Matt Mercer | last post by:
Hi all, I am having a frustration problem, and I have read about 25 newsgroup postings that do not have a satisfying answer :) The problem appears to be common where carriage returns are lost...
8
by: TheDude5B | last post by:
Hi, I have some data which is stored in my MySQL database as TEXT. when the data is entered in, it has some carriage returns in it, and this can be seen when querying the data using MySQL Query...
7
by: mattrapoport | last post by:
I have a page with a div on it. The div displays a user comment. When the user logs into this page, their current comment is pulled from a db and displayed in the div. The user can edit the...
2
by: GregBeagle | last post by:
Windows XP I have a simple form from which I want to generate an email with the contents of the form. I use carriage returns to format the content for readability. When I test it on my computer...
0
by: markus.shure | last post by:
Hi, I'm noticed a problem testing a JAX-WS client with a WSE server. The JAX-WS client adds carriage returns to a SOAP header element that is signed. This causes the WSE server to raise an...
11
by: evenlater | last post by:
My db allows the user to send email via CDO. The body of the email is determined in code. I have built an email form with To, CC and Subject lines and a large text box for the body of the message...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.