All,
I'm working on an ASP.NET 2.0 (C#) page and have a question on how to build
a string that includes line feeds (new lines) that displays properly on an
ASP.NET page. Here's what I got:
..aspx page
<asp:Label ID="LabelMoreIn formation" runat="server" Text=""></asp:Label>
code-behind for .aspx page
protected void Page_Load(objec t sender, EventArgs e)
{
string message = FormatMessage() ;
this.LabelMoreI nformation.Text = message;
}
private string FormatMessage()
{
string message = "";
System.Text.Str ingBuilder sb = new System.Text.Str ingBuilder();
// Build the message
sb.Append(Syste m.Environment.N ewLine + System.Environm ent.NewLine);
sb.Append("Date/Time: " + System.DateTime .Now.ToString(" g") +
System.Environm ent.NewLine);
sb.Append("Syst em.Environment. MachineName: " +
System.Environm ent.MachineName + System.Environm ent.NewLine);
...
sb.Append(Syste m.Environment.N ewLine + System.Environm ent.NewLine);
message = sb.ToString();
return message;
}
The problem is that the text I put in the label does not have any line
breaks/new lines. The System.Environm ent.NewLine call doesn't seem to work
when I try to then display the string on an ASP.NET page. All the text is
run together.
So, how can I get line breaks/new lines for my string information in the
above scenario? 3 5779
"retsam" <no****@company .com> wrote in message
news:O1******** ******@TK2MSFTN GP04.phx.gbl... All, I'm working on an ASP.NET 2.0 (C#) page and have a question on how to
build a string that includes line feeds (new lines) that displays properly on an ASP.NET page. Here's what I got:
.aspx page <asp:Label ID="LabelMoreIn formation" runat="server" Text=""></asp:Label>
code-behind for .aspx page protected void Page_Load(objec t sender, EventArgs e) { string message = FormatMessage() ;
this.LabelMoreI nformation.Text = message; } private string FormatMessage() { string message = ""; System.Text.Str ingBuilder sb = new System.Text.Str ingBuilder();
// Build the message sb.Append(Syste m.Environment.N ewLine +
System.Environm ent.NewLine); sb.Append("Date/Time: " + System.DateTime .Now.ToString(" g") + System.Environm ent.NewLine); sb.Append("Syst em.Environment. MachineName: " + System.Environm ent.MachineName + System.Environm ent.NewLine);
...
sb.Append(Syste m.Environment.N ewLine +
System.Environm ent.NewLine); message = sb.ToString();
return message; }
The problem is that the text I put in the label does not have any line breaks/new lines. The System.Environm ent.NewLine call doesn't seem to
work when I try to then display the string on an ASP.NET page. All the text is run together.
So, how can I get line breaks/new lines for my string information in the above scenario?
Not to glamorous, but you could insert <br> to the string and it will result
in a carriage return.
Mike
TextBox has a multiline property somewhere.
Labels.... I think you gotta "<br/>" it like the previous post said.
You gotta remember there isn't such a thing as a Label or a TextBox on the
client side.
Its going to be rendered
<textarea> or other regular html controls.
Check your output (View Source) in the browser. Once you see how an
asp:label or asp:textbox gets rendered on the client, you'll better
understand your limitations.
"vMike" <Mi************ ****@noZorY.geZ waYrrenY.com> wrote in message
news:ye******** ************@co mcast.com... "retsam" <no****@company .com> wrote in message news:O1******** ******@TK2MSFTN GP04.phx.gbl... All, I'm working on an ASP.NET 2.0 (C#) page and have a question on how to build a string that includes line feeds (new lines) that displays properly on
an ASP.NET page. Here's what I got:
.aspx page <asp:Label ID="LabelMoreIn formation" runat="server" Text=""></asp:Label>
code-behind for .aspx page protected void Page_Load(objec t sender, EventArgs e) { string message = FormatMessage() ;
this.LabelMoreI nformation.Text = message; } private string FormatMessage() { string message = ""; System.Text.Str ingBuilder sb = new System.Text.Str ingBuilder();
// Build the message sb.Append(Syste m.Environment.N ewLine + System.Environm ent.NewLine); sb.Append("Date/Time: " + System.DateTime .Now.ToString(" g") + System.Environm ent.NewLine); sb.Append("Syst em.Environment. MachineName: " + System.Environm ent.MachineName + System.Environm ent.NewLine);
...
sb.Append(Syste m.Environment.N ewLine + System.Environm ent.NewLine); message = sb.ToString();
return message; }
The problem is that the text I put in the label does not have any line breaks/new lines. The System.Environm ent.NewLine call doesn't seem to
work when I try to then display the string on an ASP.NET page. All the text
is run together.
So, how can I get line breaks/new lines for my string information in the above scenario?
Not to glamorous, but you could insert <br> to the string and it will
result in a carriage return. Mike
Thanks vMike! That worked. Before posting the message, I had tried <br />,
but that didn't work either--it was actually displaying <br />. I guess
taking the / out made it work.
Cheers
"vMike" <Mi************ ****@noZorY.geZ waYrrenY.com> wrote in message
news:ye******** ************@co mcast.com... "retsam" <no****@company .com> wrote in message news:O1******** ******@TK2MSFTN GP04.phx.gbl... All, I'm working on an ASP.NET 2.0 (C#) page and have a question on how to build a string that includes line feeds (new lines) that displays properly on
an ASP.NET page. Here's what I got:
.aspx page <asp:Label ID="LabelMoreIn formation" runat="server" Text=""></asp:Label>
code-behind for .aspx page protected void Page_Load(objec t sender, EventArgs e) { string message = FormatMessage() ;
this.LabelMoreI nformation.Text = message; } private string FormatMessage() { string message = ""; System.Text.Str ingBuilder sb = new System.Text.Str ingBuilder();
// Build the message sb.Append(Syste m.Environment.N ewLine + System.Environm ent.NewLine); sb.Append("Date/Time: " + System.DateTime .Now.ToString(" g") + System.Environm ent.NewLine); sb.Append("Syst em.Environment. MachineName: " + System.Environm ent.MachineName + System.Environm ent.NewLine);
...
sb.Append(Syste m.Environment.N ewLine + System.Environm ent.NewLine); message = sb.ToString();
return message; }
The problem is that the text I put in the label does not have any line breaks/new lines. The System.Environm ent.NewLine call doesn't seem to
work when I try to then display the string on an ASP.NET page. All the text
is run together.
So, how can I get line breaks/new lines for my string information in the above scenario?
Not to glamorous, but you could insert <br> to the string and it will
result in a carriage return. Mike
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Douglas Buchanan |
last post by:
I am using the following code instead of a very lengthly select case
statement.
(I have a lot of lookup tables in a settings form that are selected
from a ListBox. The data adapters are given a similar name to the
table. Rather than making a long Select Case that could become
obsolete if lookup tables are added and the source table of the
ListBox is edited I came up with this code.)
This code works but of course it gives me build...
|
by: Dave Reid |
last post by:
Hi everyone...
I'm pretty much a newbie C++ user, and I've run into a problem.
I'm trying to read in a large text file, and then do manipulations on
it. I can read it into a large 2-dimensional character array, but I'd
really like to read it into a vector of strings. Here's how I'm doing
the read into the char array:
int main() {
string str1("booger");
string str2("test");
|
by: Jon |
last post by:
Hi all,
I am trying to create a page that contains a number of div elements,
with links on the left side of the page allowing the user to select
which div to display. Some of the pages contain tables with border
styles used to block off the columns and the headers, but not the
individual rows. The pages will be displayed using IE 5.5 and later
in the finished app. Now to the problem, which is a little awkward to
describe:
|
by: Karsten Grombach |
last post by:
How can I display the current build version of my webapplication at runtime?
i.e. the version I set in my web deployment project.
regards and thanks
karsten
|
by: Bauer |
last post by:
I am new to GDI+.I am drawing a string on the Win form
using GDI+. My string content is long and it does not
have any "vbcrlf". The whole string is displayed in a
single line and is getting truncated. Can anyone tell me
how to take the win form bounds and display the long
content on multiple lines.
The same is happening when i am printing the same string.
how do i take the page settings and print the page
Thanks in advance
| |
by: thuyptt |
last post by:
Hi you!!
I am programming a part of my application and I met a trouble in
display test.
I used fgets to read each line in a text file and display all lines on
the screen. But the size of the window are too small to display all the
line(208,320), So can I ask you how to divide split a string(a line in
file) into many lines and dis play them on the screen so that all the
characters of the string would be displayed fully.
|
by: dasilva109 |
last post by:
Hi guys
I am new to C++ and need urgent help with this part of my code for a
uni coursework I have to submit by Thursday
//ClientData.h
#ifndef CLIENTDATA_H
#define CLIENTDATA_H
#include <string>
|
by: Diffident |
last post by:
Hi All,
How can I prevent my end users from noticing an error when we are
re-compiling our project? Is there any way? Or how can we show a
user-friendly message when we are recompiling the project?
Thanks a bunch!!!
|
by: ge0193387 |
last post by:
I'm attempting to make a custom control that will let me drag drop
images onto a web form and display the image in that same box. Any
details on how to make that easier without turning me to a page
telling me how to move images on the page itself or the javascript
animation control (which is what I'm basing this on) would be
extremely helpful.
As for the build errors I'm attempting to debug my code but my build
errors aren't showing up...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |