473,405 Members | 2,415 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,405 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 17 '05 #1
4 2290
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 17 '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 17 '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 17 '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 17 '05 #5

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

Similar topics

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...
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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...
0
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...
0
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...
0
agi2029
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,...

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.