Carriage Returns

Discussion in 'ASP .Net' started by =?Utf-8?B?SSBhbSBTYW0=?=, Oct 15, 2004.

  1. 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-
     
    =?Utf-8?B?SSBhbSBTYW0=?=, Oct 15, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?SSBhbSBTYW0=?=

    Matt Berther Guest

    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-
    >
     
    Matt Berther, Oct 16, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Iceberg

    Carriage Returns and sockets

    Iceberg, Sep 6, 2003, in forum: Perl
    Replies:
    1
    Views:
    1,171
    Iceberg
    Sep 6, 2003
  2. Schroeder
    Replies:
    1
    Views:
    574
    Jim Gibson
    Jan 26, 2005
  3. Mario Vargas

    Replacing Carriage Returns in VB.NET

    Mario Vargas, Oct 21, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    14,643
    Dragos Marian Barbu
    Nov 10, 2003
  4. Brian
    Replies:
    1
    Views:
    312
    Craig Deelsnyder
    Jun 17, 2004
  5. Steve Anderson
    Replies:
    3
    Views:
    271
    Steve Anderson
    Jun 21, 2004
Loading...

Share This Page