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

How do I repeat html output in aspnet and c#?

Hi,

Maybe is a simple question but I found difficult to find the answer.

Context:
I am creating a site where designers ONLY touch the ASPX page and I.S. touch
the code behind.

Task:
I have a simple page that list a number of offers based on info from the
system (no dabatase, no bound objects please)

Problem:
In old ASP this task it was quite simple, just create the layout once and
then you repeat it using a <% for .... %>. This gives the designer the
ability to change the entry and it will be repeated several time:

Example Old ASP:
<% for (int i = 0; i < Total; i++) { %>
<TR>
<TD>
Here goes my entry where you can design me!, number <%= i %>
</TD>
</TR>

This is easy and great, now, how can I do this on ASPNET? If I use ASPNET
tags it does not allow me to use code blocks, also, I though about creating a
usercontrol with the entry design and then dynamically addedd to a
table....mmmm... it doesn't work cause I need to register the usercontrol but
it can be 10, or event 20 times plotted on the page, cause I don't know the
amount of usercontrols until I process the page. (this solution works great
in a windows applicaiton but it seems hard stuff for ASPNET)

Hope this makes sense, is a very simple thing to do but is hard to find the
answer.

Thansk in advance
--
Salvador

Nov 19 '05 #1
4 1200
Salvador,

You need to use a Repeater control. You will define an ItemTemplate and
databind it (I know, you asked for no bound object, but that's the way) to a
datasource. The datasource doesn't have to be a database table. It can be an
array. Have a look at ASP.NET data binding overview here:
http://support.microsoft.com/default...b;en-us;307860

Eliyahu

"Salvador" <Sa******@discussions.microsoft.com> wrote in message
news:C2**********************************@microsof t.com...
Hi,

Maybe is a simple question but I found difficult to find the answer.

Context:
I am creating a site where designers ONLY touch the ASPX page and I.S. touch the code behind.

Task:
I have a simple page that list a number of offers based on info from the
system (no dabatase, no bound objects please)

Problem:
In old ASP this task it was quite simple, just create the layout once and
then you repeat it using a <% for .... %>. This gives the designer the
ability to change the entry and it will be repeated several time:

Example Old ASP:
<% for (int i = 0; i < Total; i++) { %>
<TR>
<TD>
Here goes my entry where you can design me!, number <%= i %>
</TD>
</TR>

This is easy and great, now, how can I do this on ASPNET? If I use ASPNET
tags it does not allow me to use code blocks, also, I though about creating a usercontrol with the entry design and then dynamically addedd to a
table....mmmm... it doesn't work cause I need to register the usercontrol but it can be 10, or event 20 times plotted on the page, cause I don't know the amount of usercontrols until I process the page. (this solution works great in a windows applicaiton but it seems hard stuff for ASPNET)

Hope this makes sense, is a very simple thing to do but is hard to find the answer.

Thansk in advance
--
Salvador

Nov 19 '05 #2
You have several options here :
- using Response.Write is still possible. I'm not using the intermixed
style. You may want to post the exact error. Using this in code works...
- in ASP.NET you would rather use "controls". Actually here you could have a
single asp:Table control (an HTML table) in which your code will dynamically
add lines as needed...
(you could also use DataBind even with if your data are not coming from a
DB).
- or you could use a Repeater to repeat the same HTML template for each
source line

The whole idea behind ASP.NET is to control HTML rendering through a server
side programming model that models the "objects" you'll find on your final
page client side...

http://samples.gotdotnet.com/quickst...ing.aspx#lists
and around may help to get started with ASP.NET

Patrice

--

"Salvador" <Sa******@discussions.microsoft.com> a écrit dans le message de
news:C2**********************************@microsof t.com...
Hi,

Maybe is a simple question but I found difficult to find the answer.

Context:
I am creating a site where designers ONLY touch the ASPX page and I.S. touch the code behind.

Task:
I have a simple page that list a number of offers based on info from the
system (no dabatase, no bound objects please)

Problem:
In old ASP this task it was quite simple, just create the layout once and
then you repeat it using a <% for .... %>. This gives the designer the
ability to change the entry and it will be repeated several time:

Example Old ASP:
<% for (int i = 0; i < Total; i++) { %>
<TR>
<TD>
Here goes my entry where you can design me!, number <%= i %>
</TD>
</TR>

This is easy and great, now, how can I do this on ASPNET? If I use ASPNET
tags it does not allow me to use code blocks, also, I though about creating a usercontrol with the entry design and then dynamically addedd to a
table....mmmm... it doesn't work cause I need to register the usercontrol but it can be 10, or event 20 times plotted on the page, cause I don't know the amount of usercontrols until I process the page. (this solution works great in a windows applicaiton but it seems hard stuff for ASPNET)

Hope this makes sense, is a very simple thing to do but is hard to find the answer.

Thansk in advance
--
Salvador

Nov 19 '05 #3
Forgot to mention that your designers are the ones who will make the
template.

Eliyahu

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Salvador,

You need to use a Repeater control. You will define an ItemTemplate and
databind it (I know, you asked for no bound object, but that's the way) to a datasource. The datasource doesn't have to be a database table. It can be an array. Have a look at ASP.NET data binding overview here:
http://support.microsoft.com/default...b;en-us;307860

Eliyahu

"Salvador" <Sa******@discussions.microsoft.com> wrote in message
news:C2**********************************@microsof t.com...
Hi,

Maybe is a simple question but I found difficult to find the answer.

Context:
I am creating a site where designers ONLY touch the ASPX page and I.S. touch
the code behind.

Task:
I have a simple page that list a number of offers based on info from the
system (no dabatase, no bound objects please)

Problem:
In old ASP this task it was quite simple, just create the layout once and then you repeat it using a <% for .... %>. This gives the designer the
ability to change the entry and it will be repeated several time:

Example Old ASP:
<% for (int i = 0; i < Total; i++) { %>
<TR>
<TD>
Here goes my entry where you can design me!, number <%= i %>
</TD>
</TR>

This is easy and great, now, how can I do this on ASPNET? If I use ASPNET tags it does not allow me to use code blocks, also, I though about

creating a
usercontrol with the entry design and then dynamically addedd to a
table....mmmm... it doesn't work cause I need to register the

usercontrol but
it can be 10, or event 20 times plotted on the page, cause I don't know

the
amount of usercontrols until I process the page. (this solution works

great
in a windows applicaiton but it seems hard stuff for ASPNET)

Hope this makes sense, is a very simple thing to do but is hard to find

the
answer.

Thansk in advance
--
Salvador


Nov 19 '05 #4
On Wed, 22 Jun 2005 04:28:02 -0700, Salvador wrote:
Hi,

Maybe is a simple question but I found difficult to find the answer.

Context:
I am creating a site where designers ONLY touch the ASPX page and I.S. touch
the code behind.

Task:
I have a simple page that list a number of offers based on info from the
system (no dabatase, no bound objects please)

Problem:
In old ASP this task it was quite simple, just create the layout once and
then you repeat it using a <% for .... %>. This gives the designer the
ability to change the entry and it will be repeated several time:

Example Old ASP:
<% for (int i = 0; i < Total; i++) { %>
<TR>
<TD>
Here goes my entry where you can design me!, number <%= i %>
</TD>
</TR>

This is easy and great, now, how can I do this on ASPNET? If I use ASPNET
tags it does not allow me to use code blocks, also, I though about creating a
usercontrol with the entry design and then dynamically addedd to a
table....mmmm... it doesn't work cause I need to register the usercontrol but
it can be 10, or event 20 times plotted on the page, cause I don't know the
amount of usercontrols until I process the page. (this solution works great
in a windows applicaiton but it seems hard stuff for ASPNET)

Hope this makes sense, is a very simple thing to do but is hard to find the
answer.

Thansk in advance

Quite difficult to really separate the View from the Controller and/or
Model. .Net gives you the impression that this would be easy, but it is
only true for the most trivial cases.
I would try in order:
1. Use data binding
2. Use repeaters or other complex list controls
3. Do your own rendering replacing stuff as needed in a template
4. Use templates, but here the designers/coders are mixing.
5. Use <% %> as last resort and keep it simple

Nov 19 '05 #5

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

Similar topics

4
by: Salvador | last post by:
Hi, Maybe is a simple question but I found difficult to find the answer. Context: I am creating a site where designers ONLY touch the ASPX page and I.S. touch the code behind. Task: I...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
4
by: Ivan Demkovitch | last post by:
Hi! I wonder if I get any performance hit when I do following with some of my user controls: I don't have HTML section, but instead, I use code like; this.Controls.Add(new...
2
by: Brian Henry | last post by:
Is there anyway to force the output HTML from asp.net to be optimized? for example tabs removed, white space between tags remove, comments removed, etc (to reduce output page size) frontpage 2003...
6
by: Peter Strøiman | last post by:
Hi. I have a situation where I have a web project and a class library in the same solution. The web project uses the class library. Therefore, I created a "project reference" in the web project...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
6
by: dpomt | last post by:
I have a quite strange problem with the Menu control. I have ten languages and each language has a SiteMapDataSource and a Menu. For better performance, I am creating a hashtable (language ->...
12
by: Nalaka | last post by:
Hi, I suddenly started getting a lot of errors from html validation (some CSS) so I followed the following instructions to disable it. If you'd rather not have these types of HTML validation...
1
kestrel
by: kestrel | last post by:
im using externl css, and i have a menu, and i want to add some css, thta will make an image repeat at the top of my page. i dont know how to sup into my html file, div or what ever. thanks ...
2
XedinUnknown
by: XedinUnknown | last post by:
Hi! I am new to this forum, but not new to web design and programming. Nevertheless, I have never tried to use PNG so extensively in my pages. here's the problem. First, I have found that the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.