473,796 Members | 2,728 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Write HTML in run time using C#

Yiu
Here is my code:

private static ArrayList info=new ArrayList();
private Label[] label;

private void Page_Load(objec t sender, System.EventArg s e)
{
label=new Label[info.Count];

Response.Write( "<table width=75%border =1>");
for(int cnt=info.Count; cnt>0;cnt--)
{
Response.Write( "<tr>");
Response.Write( "<td>");
label[cnt-1]=new Label();
label[cnt-1].Text=(String)i nfo[cnt-1];
Page.Controls.A dd(label[cnt-1]);
Response.Write( "</td>");
Response.Write( "</tr>");
}
Response.Write( "</table>");
}
public static void setInfo(String s)
{
info.Add(s);
}

I want to create a new line between each label in run time, but i
cannot do this to create new line between label when use the code
above, have any good suggestion for me to solve this problem?
Nov 18 '05 #1
3 14831
On your line Response.Write( "</table>");
Change to
Response.Write( "</table><br>");

On 5 Mar 2004 23:46:49 -0800, bi********@yaho o.com.hk (Yiu) wrote:
Here is my code:

private static ArrayList info=new ArrayList();
private Label[] label;

private void Page_Load(objec t sender, System.EventArg s e)
{
label=new Label[info.Count];

Response.Write( "<table width=75%border =1>");
for(int cnt=info.Count; cnt>0;cnt--)
{
Response.Write( "<tr>");
Response.Write( "<td>");
label[cnt-1]=new Label();
label[cnt-1].Text=(String)i nfo[cnt-1];
Page.Controls.A dd(label[cnt-1]);
Response.Write( "</td>");
Response.Write( "</tr>");
}
Response.Write( "</table>");
}
public static void setInfo(String s)
{
info.Add(s);
}

I want to create a new line between each label in run time, but i
cannot do this to create new line between label when use the code
above, have any good suggestion for me to solve this problem?


Nov 18 '05 #2
Hi,
I want to create a new line between each label in run time, but i
cannot do this to create new line between label when use the code
above, have any good suggestion for me to solve this problem?


You could insert a blank row between each label

Response.Write( "<tr><td>&nbsp; </td></tr>");

or use a CSS class to control the height of each table cell or the
label itself (labels get rendered as spans)

Regards
Charlie
Nov 18 '05 #3
Yiu
Below is my new code:
for(int cnt=info.Count; cnt>0;cnt--)
{
label[cnt-1]=new Label();
label[cnt-1].Text=(String)i nfo[cnt-1];
Page.Controls.A dd(label[cnt-1]);
Page.Response.W rite("<tr><td>& nbsp;</td></tr>");
}

But have something wrong in the output, the <tr><td>&nbsp ;</td></tr>
not print between the label, it print at the head of the HTML.Why?Have
solution?
<span>Free</span><span>Scie nce Museum</span> is my Label output.

Below is my HTML output after add Label use the code above:
<tr><td>&nbsp ;</td></tr><tr><td>&nbs p;</td></tr>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>ShowInfo rmation</title>
<meta content="Micros oft Visual Studio .NET 7.1" name="GENERATOR ">
<meta content="C#" name="CODE_LANG UAGE">
<meta content="JavaSc ript" name="vs_defaul tClientScript">
<meta content="http://schemas.microso ft.com/intellisense/ie5"
name="vs_target Schema">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form name="Form1" method="post" action="ShowInf ormation.aspx"
id="Form1">
<input type="hidden" name="__VIEWSTA TE"
value="dDwtNTMw NzcxMzI0Ozs+XUG diuz4iPEe85152U YL3O0Fa+A=" />

<FONT face="新細明體">
<input type="submit" name="BackButto n" value="Back"
id="BackButton " style="height:3 2px;width:64px; Z-INDEX: 101; LEFT:
24px; POSITION: absolute; TOP: 288px" /></FONT></form>
</body>
</HTML>
<span>Free</span><span>Scie nce Museum</span>
Nov 18 '05 #4

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

Similar topics

14
3060
by: Michael Levin | last post by:
I've got the following problem. I'm a biologist and I have a device at work which monitors my frog habitat. The device has a bunch of sensors, and runs an embedded html server with some java functions defined which know how to read the hardware sensorts. I access it from wherever I am via any browser, and it displays the measurements (a set of simple numbers) as Java applets in a simple html page. One entry in this page (a table cell) looks...
6
12988
by: Mike Daniel | last post by:
I am attempting to use document.write(pageVar) that displays a new html page within a pop-up window and the popup is failing. Also note that pageVar is a complete HTML page containing other java scripts. Being a javascript newbie and after significant testing, I suspect that the document.write fails after finding a </script> within pageVar. Does a trick exist that enables one to slightly alter pageVar whereby enabling...
13
9651
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be assigned to a variable and output using document.write. (Note, there is no submit button or other form elements. Basically
14
4130
by: Eli | last post by:
I've got a script that I'm trying to debug which uses document.write() to place HTML within a page. In both IE6 and Firefox when I view source, I see only the script itself and not any HTML as it's being written into the page. Is there a way that I can view what is being placed into the page, instead of, or in addition to the javascript code?
18
4895
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE) p.stdin.write("hostname\n") however, it doesn't seem to work. I think the cmd.exe is catching it.
2
3624
by: robert.waters | last post by:
Hello, I am dynamically editing the contents of a page and using document.write() to reload the new, edited content. However, on the new page, any calls to functions located in external .js files (fyi: same domain) fail with 'object expected' (IE6). If I subsequently reload the page, everything works. Also, if I inline this code, everything works. Here is an example: (called from body onload event) (This just rewrites the page with...
14
3153
by: WUV999U | last post by:
Hi I am fairly familiar in C but not much. I want to know how I can write a html parser in C that only parses for the image file in the html file and display or print all the images found in the html file. How to go about it?
88
8097
by: Peter Olcott | last post by:
Cab you write code directly in the Common Intermediate language? I need to optimize a critical real-time function.
0
3588
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this OleDbParameterCollection" whenI try to write a new record. Delete and Modify work fine its just the add record function causes the error.
21
1920
by: Raj | last post by:
Hi, We just executed a project with Python using TG. The feedback was to use more python like programming rather than C style code executed in Python. The feedback is from a Python purist and for some reasons we cannot solicity his help. So we'd like to do is to scrub through the codebase and identify places where the codebase needs improvement, both from styling as well as design. Is there any website that can provide me with...
0
9685
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, 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...
0
9535
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10244
jinu1996
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...
1
10201
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7558
isladogs
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...
0
6802
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4130
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
3
2931
bsmnconsultancy
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...

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.