473,772 Members | 3,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is this possible...

Hi,

Does anyone know if it is possible to put an aspx page inside of another? OR
run an aspx page and capture the output as a string and then write this out
to a page....

So for example say you have a page that takes an id number as a query string
and displays different things based on that id number.

If you were able to loop through running the aspx pages with id=100, id=200,
id=300 etc and on each loop capture the output as a string and then
response.write it out on the page this script was being executed, the end
result would be the page shown over and over again one after the other but
as if each had been run with a different id number?


Dec 30 '05 #1
8 1909
Hi Daniel,

I think you need to back up a bit. You're talking about a solution, but you
haven't described the requirement. The solution is always based first upon
the requirement (in purely abstract terms), and upon the available resources
for satisfying the requirement.

The difference is that when you talk about puttting ASPX pages inside one
another, you're talking about a solution. The requirement would be more
along the lines of "I want to display a variable number of database records
on a page," or "I want to display one record on a page, and have a link to
the next page." It might include such requirements as "The page body should
look the same."

An ASPX Page is an HTTP Handler. There are situations in which you might
want to embed the output of one ASPX Page inside another, and you can use
Server.Transfer to accomplish this, but these situations are relatively
rare. Most of the time, Server Controls are used for this sort of thing.
Without knowing your requirements, it isn't possible to advise you as to the
correct solution.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Daniel" <Da*****@vestry online.com> wrote in message
news:ui******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

Does anyone know if it is possible to put an aspx page inside of another?
OR run an aspx page and capture the output as a string and then write this
out to a page....

So for example say you have a page that takes an id number as a query
string and displays different things based on that id number.

If you were able to loop through running the aspx pages with id=100,
id=200, id=300 etc and on each loop capture the output as a string and
then response.write it out on the page this script was being executed, the
end result would be the page shown over and over again one after the other
but as if each had been run with a different id number?

Dec 30 '05 #2
Hi Kevin,

Thank you for replying. A very long way of saying 'why do you want to do
that' but i will explain :)

I have posted this elsewhere in detail and had a few replies but its
difficult to explain so i will try again here.

I have made an invoice in old asp a while ago. It did the following:

1) looped through the database retrieving all the orderids of open orders
2) For each it found it then retrieved the sub parts of that order, e.g. tin
of beans £10, tin of tuna £5 etc
3) It then wrote this out building the complete page on the fly in a table,
putting in the company logo, address, delivery address....made the invoice
basically.
4) Once the first invoice is done I then created a page break (using CSS) to
force a new page and write the next invoice etc

So once finished i had a load of invoices one after the other in a web page,
then i press print and out they come ready for dispatch.

With that in mind i now want to update that page to do the same task in
asp.net. I now have some new stationary, paper with a peel off label
attached.

So i now need the exact same thing achieved but with the exact position of
the delivery address to match with the label, in .net using absolute
positioning and the lovely interface this didnt take long and so i have
created my .net page to take an order id and create my invoice with
everything where it should be.

All make sense so far?

My problem is as with my original, i want it to now move onto the second
invoice, create a new page, and repeat....then to the net and so on.

I want to avoid making a page that writes out html tags like my original
asp page and builds the tables on the fly.

So i have looked at putting it all in a panel and then making a new panel on
the fly for the second invoice and placing this one on a new page using my
css break to break them apart on a new page. Problem is i dont seem to be
able to get the panel position programatically in order to do this. (i also
dont even know if that is a viable solution)

Another option which i was checking with my original question was to run and
embed the output of the single page that does work, changing the querystring
to each order id.....i agree it is very inefficient but it would work. Then
i could put my css page break between each output stream.

I hope that all makes sense, if you can help i would be very grateful

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ex******** *****@TK2MSFTNG P12.phx.gbl...
Hi Daniel,

I think you need to back up a bit. You're talking about a solution, but
you haven't described the requirement. The solution is always based first
upon the requirement (in purely abstract terms), and upon the available
resources for satisfying the requirement.

The difference is that when you talk about puttting ASPX pages inside one
another, you're talking about a solution. The requirement would be more
along the lines of "I want to display a variable number of database
records on a page," or "I want to display one record on a page, and have a
link to the next page." It might include such requirements as "The page
body should look the same."

An ASPX Page is an HTTP Handler. There are situations in which you might
want to embed the output of one ASPX Page inside another, and you can use
Server.Transfer to accomplish this, but these situations are relatively
rare. Most of the time, Server Controls are used for this sort of thing.
Without knowing your requirements, it isn't possible to advise you as to
the correct solution.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Daniel" <Da*****@vestry online.com> wrote in message
news:ui******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

Does anyone know if it is possible to put an aspx page inside of another?
OR run an aspx page and capture the output as a string and then write
this out to a page....

So for example say you have a page that takes an id number as a query
string and displays different things based on that id number.

If you were able to loop through running the aspx pages with id=100,
id=200, id=300 etc and on each loop capture the output as a string and
then response.write it out on the page this script was being executed,
the end result would be the page shown over and over again one after the
other but as if each had been run with a different id number?


Dec 30 '05 #3
Sounds like a job for usercontrols. You can create a usercontrol that has
all the elements necessary to render one particular invoice. Then on the
main page, you can have all your main elements such as the header and so on
(possible include like a placeholder or something for later use like a
<div>). When the main page is processed, you would then loop through all
your IDs and dynamically load each user control providing it just enough
information to render itself using the LoadControl method. You would then
add this newly loaded control to the Control collection of your placeholder.

"Daniel" <Da*****@vestry online.com> wrote in message
news:eS******** *****@TK2MSFTNG P11.phx.gbl...
Hi Kevin,

Thank you for replying. A very long way of saying 'why do you want to do
that' but i will explain :)

I have posted this elsewhere in detail and had a few replies but its
difficult to explain so i will try again here.

I have made an invoice in old asp a while ago. It did the following:

1) looped through the database retrieving all the orderids of open orders
2) For each it found it then retrieved the sub parts of that order, e.g.
tin of beans £10, tin of tuna £5 etc
3) It then wrote this out building the complete page on the fly in a
table, putting in the company logo, address, delivery address....made the
invoice basically.
4) Once the first invoice is done I then created a page break (using CSS)
to force a new page and write the next invoice etc

So once finished i had a load of invoices one after the other in a web
page, then i press print and out they come ready for dispatch.

With that in mind i now want to update that page to do the same task in
asp.net. I now have some new stationary, paper with a peel off label
attached.

So i now need the exact same thing achieved but with the exact position of
the delivery address to match with the label, in .net using absolute
positioning and the lovely interface this didnt take long and so i have
created my .net page to take an order id and create my invoice with
everything where it should be.

All make sense so far?

My problem is as with my original, i want it to now move onto the second
invoice, create a new page, and repeat....then to the net and so on.

I want to avoid making a page that writes out html tags like my original
asp page and builds the tables on the fly.

So i have looked at putting it all in a panel and then making a new panel
on the fly for the second invoice and placing this one on a new page using
my css break to break them apart on a new page. Problem is i dont seem to
be able to get the panel position programatically in order to do this. (i
also dont even know if that is a viable solution)

Another option which i was checking with my original question was to run
and embed the output of the single page that does work, changing the
querystring to each order id.....i agree it is very inefficient but it
would work. Then i could put my css page break between each output stream.

I hope that all makes sense, if you can help i would be very grateful

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ex******** *****@TK2MSFTNG P12.phx.gbl...
Hi Daniel,

I think you need to back up a bit. You're talking about a solution, but
you haven't described the requirement. The solution is always based first
upon the requirement (in purely abstract terms), and upon the available
resources for satisfying the requirement.

The difference is that when you talk about puttting ASPX pages inside one
another, you're talking about a solution. The requirement would be more
along the lines of "I want to display a variable number of database
records on a page," or "I want to display one record on a page, and have
a link to the next page." It might include such requirements as "The page
body should look the same."

An ASPX Page is an HTTP Handler. There are situations in which you might
want to embed the output of one ASPX Page inside another, and you can use
Server.Transfer to accomplish this, but these situations are relatively
rare. Most of the time, Server Controls are used for this sort of thing.
Without knowing your requirements, it isn't possible to advise you as to
the correct solution.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Daniel" <Da*****@vestry online.com> wrote in message
news:ui******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

Does anyone know if it is possible to put an aspx page inside of
another? OR run an aspx page and capture the output as a string and then
write this out to a page....

So for example say you have a page that takes an id number as a query
string and displays different things based on that id number.

If you were able to loop through running the aspx pages with id=100,
id=200, id=300 etc and on each loop capture the output as a string and
then response.write it out on the page this script was being executed,
the end result would be the page shown over and over again one after the
other but as if each had been run with a different id number?



Dec 30 '05 #4
To fix positing, you might need to resort to using tables to help you layout
your content. I assume that you were trying to position the panel using
CSS. Set the width and height for the table cells will allow you to
position elements you necessary with some precision.

"Daniel" <Da*****@vestry online.com> wrote in message
news:eS******** *****@TK2MSFTNG P11.phx.gbl...
Hi Kevin,

Thank you for replying. A very long way of saying 'why do you want to do
that' but i will explain :)

I have posted this elsewhere in detail and had a few replies but its
difficult to explain so i will try again here.

I have made an invoice in old asp a while ago. It did the following:

1) looped through the database retrieving all the orderids of open orders
2) For each it found it then retrieved the sub parts of that order, e.g.
tin of beans £10, tin of tuna £5 etc
3) It then wrote this out building the complete page on the fly in a
table, putting in the company logo, address, delivery address....made the
invoice basically.
4) Once the first invoice is done I then created a page break (using CSS)
to force a new page and write the next invoice etc

So once finished i had a load of invoices one after the other in a web
page, then i press print and out they come ready for dispatch.

With that in mind i now want to update that page to do the same task in
asp.net. I now have some new stationary, paper with a peel off label
attached.

So i now need the exact same thing achieved but with the exact position of
the delivery address to match with the label, in .net using absolute
positioning and the lovely interface this didnt take long and so i have
created my .net page to take an order id and create my invoice with
everything where it should be.

All make sense so far?

My problem is as with my original, i want it to now move onto the second
invoice, create a new page, and repeat....then to the net and so on.

I want to avoid making a page that writes out html tags like my original
asp page and builds the tables on the fly.

So i have looked at putting it all in a panel and then making a new panel
on the fly for the second invoice and placing this one on a new page using
my css break to break them apart on a new page. Problem is i dont seem to
be able to get the panel position programatically in order to do this. (i
also dont even know if that is a viable solution)

Another option which i was checking with my original question was to run
and embed the output of the single page that does work, changing the
querystring to each order id.....i agree it is very inefficient but it
would work. Then i could put my css page break between each output stream.

I hope that all makes sense, if you can help i would be very grateful

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ex******** *****@TK2MSFTNG P12.phx.gbl...
Hi Daniel,

I think you need to back up a bit. You're talking about a solution, but
you haven't described the requirement. The solution is always based first
upon the requirement (in purely abstract terms), and upon the available
resources for satisfying the requirement.

The difference is that when you talk about puttting ASPX pages inside one
another, you're talking about a solution. The requirement would be more
along the lines of "I want to display a variable number of database
records on a page," or "I want to display one record on a page, and have
a link to the next page." It might include such requirements as "The page
body should look the same."

An ASPX Page is an HTTP Handler. There are situations in which you might
want to embed the output of one ASPX Page inside another, and you can use
Server.Transfer to accomplish this, but these situations are relatively
rare. Most of the time, Server Controls are used for this sort of thing.
Without knowing your requirements, it isn't possible to advise you as to
the correct solution.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Daniel" <Da*****@vestry online.com> wrote in message
news:ui******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

Does anyone know if it is possible to put an aspx page inside of
another? OR run an aspx page and capture the output as a string and then
write this out to a page....

So for example say you have a page that takes an id number as a query
string and displays different things based on that id number.

If you were able to loop through running the aspx pages with id=100,
id=200, id=300 etc and on each loop capture the output as a string and
then response.write it out on the page this script was being executed,
the end result would be the page shown over and over again one after the
other but as if each had been run with a different id number?



Dec 30 '05 #5
Hi Daniel,

Sounds like a Repeater Control to me. Have you looked into it?

The issue here is that an ASP.Net page is designed to render an entire HTML
document. While it can do otherwise, Server Controls are specifically
designed to render HTML *in* HTML documents. So, a Repeater Control will
render the same HTML over an over again, which it sounds like you want to
do.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Daniel" <Da*****@vestry online.com> wrote in message
news:eS******** *****@TK2MSFTNG P11.phx.gbl...
Hi Kevin,

Thank you for replying. A very long way of saying 'why do you want to do
that' but i will explain :)

I have posted this elsewhere in detail and had a few replies but its
difficult to explain so i will try again here.

I have made an invoice in old asp a while ago. It did the following:

1) looped through the database retrieving all the orderids of open orders
2) For each it found it then retrieved the sub parts of that order, e.g.
tin of beans £10, tin of tuna £5 etc
3) It then wrote this out building the complete page on the fly in a
table, putting in the company logo, address, delivery address....made the
invoice basically.
4) Once the first invoice is done I then created a page break (using CSS)
to force a new page and write the next invoice etc

So once finished i had a load of invoices one after the other in a web
page, then i press print and out they come ready for dispatch.

With that in mind i now want to update that page to do the same task in
asp.net. I now have some new stationary, paper with a peel off label
attached.

So i now need the exact same thing achieved but with the exact position of
the delivery address to match with the label, in .net using absolute
positioning and the lovely interface this didnt take long and so i have
created my .net page to take an order id and create my invoice with
everything where it should be.

All make sense so far?

My problem is as with my original, i want it to now move onto the second
invoice, create a new page, and repeat....then to the net and so on.

I want to avoid making a page that writes out html tags like my original
asp page and builds the tables on the fly.

So i have looked at putting it all in a panel and then making a new panel
on the fly for the second invoice and placing this one on a new page using
my css break to break them apart on a new page. Problem is i dont seem to
be able to get the panel position programatically in order to do this. (i
also dont even know if that is a viable solution)

Another option which i was checking with my original question was to run
and embed the output of the single page that does work, changing the
querystring to each order id.....i agree it is very inefficient but it
would work. Then i could put my css page break between each output stream.

I hope that all makes sense, if you can help i would be very grateful

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ex******** *****@TK2MSFTNG P12.phx.gbl...
Hi Daniel,

I think you need to back up a bit. You're talking about a solution, but
you haven't described the requirement. The solution is always based first
upon the requirement (in purely abstract terms), and upon the available
resources for satisfying the requirement.

The difference is that when you talk about puttting ASPX pages inside one
another, you're talking about a solution. The requirement would be more
along the lines of "I want to display a variable number of database
records on a page," or "I want to display one record on a page, and have
a link to the next page." It might include such requirements as "The page
body should look the same."

An ASPX Page is an HTTP Handler. There are situations in which you might
want to embed the output of one ASPX Page inside another, and you can use
Server.Transfer to accomplish this, but these situations are relatively
rare. Most of the time, Server Controls are used for this sort of thing.
Without knowing your requirements, it isn't possible to advise you as to
the correct solution.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Daniel" <Da*****@vestry online.com> wrote in message
news:ui******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

Does anyone know if it is possible to put an aspx page inside of
another? OR run an aspx page and capture the output as a string and then
write this out to a page....

So for example say you have a page that takes an id number as a query
string and displays different things based on that id number.

If you were able to loop through running the aspx pages with id=100,
id=200, id=300 etc and on each loop capture the output as a string and
then response.write it out on the page this script was being executed,
the end result would be the page shown over and over again one after the
other but as if each had been run with a different id number?



Dec 30 '05 #6
Hi Kevin/Peter

Peter - User controls sounds ideal not sure how to sort the new page issue
with it tho, i could look into a way of padding it. So if i understand you
right i make a control that draws the invoice and take a var of orderid,
then just keep making new instances one after the other for each order id?
Sounds like a good solution

Kevin - Yes i had looked at repeaters but I have never used them before and
was not sure if they can handle absolutely positioned items, if i understand
right a repeater needs a template given to it, so i woul dhave to pass in my
full structure of my table layout but use the databinder.eval where the vars
would go. Is that right? If you can provide some sample code on a very basic
repeater that would help.

Either way thanks a million for both your responses.

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:OH******** ******@TK2MSFTN GP09.phx.gbl...
Hi Daniel,

Sounds like a Repeater Control to me. Have you looked into it?

The issue here is that an ASP.Net page is designed to render an entire
HTML document. While it can do otherwise, Server Controls are specifically
designed to render HTML *in* HTML documents. So, a Repeater Control will
render the same HTML over an over again, which it sounds like you want to
do.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Daniel" <Da*****@vestry online.com> wrote in message
news:eS******** *****@TK2MSFTNG P11.phx.gbl...
Hi Kevin,

Thank you for replying. A very long way of saying 'why do you want to do
that' but i will explain :)

I have posted this elsewhere in detail and had a few replies but its
difficult to explain so i will try again here.

I have made an invoice in old asp a while ago. It did the following:

1) looped through the database retrieving all the orderids of open orders
2) For each it found it then retrieved the sub parts of that order, e.g.
tin of beans £10, tin of tuna £5 etc
3) It then wrote this out building the complete page on the fly in a
table, putting in the company logo, address, delivery address....made the
invoice basically.
4) Once the first invoice is done I then created a page break (using CSS)
to force a new page and write the next invoice etc

So once finished i had a load of invoices one after the other in a web
page, then i press print and out they come ready for dispatch.

With that in mind i now want to update that page to do the same task in
asp.net. I now have some new stationary, paper with a peel off label
attached.

So i now need the exact same thing achieved but with the exact position
of the delivery address to match with the label, in .net using absolute
positioning and the lovely interface this didnt take long and so i have
created my .net page to take an order id and create my invoice with
everything where it should be.

All make sense so far?

My problem is as with my original, i want it to now move onto the second
invoice, create a new page, and repeat....then to the net and so on.

I want to avoid making a page that writes out html tags like my original
asp page and builds the tables on the fly.

So i have looked at putting it all in a panel and then making a new panel
on the fly for the second invoice and placing this one on a new page
using my css break to break them apart on a new page. Problem is i dont
seem to be able to get the panel position programatically in order to do
this. (i also dont even know if that is a viable solution)

Another option which i was checking with my original question was to run
and embed the output of the single page that does work, changing the
querystring to each order id.....i agree it is very inefficient but it
would work. Then i could put my css page break between each output
stream.

I hope that all makes sense, if you can help i would be very grateful

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ex******** *****@TK2MSFTNG P12.phx.gbl...
Hi Daniel,

I think you need to back up a bit. You're talking about a solution, but
you haven't described the requirement. The solution is always based
first upon the requirement (in purely abstract terms), and upon the
available resources for satisfying the requirement.

The difference is that when you talk about puttting ASPX pages inside
one another, you're talking about a solution. The requirement would be
more along the lines of "I want to display a variable number of database
records on a page," or "I want to display one record on a page, and have
a link to the next page." It might include such requirements as "The
page body should look the same."

An ASPX Page is an HTTP Handler. There are situations in which you might
want to embed the output of one ASPX Page inside another, and you can
use Server.Transfer to accomplish this, but these situations are
relatively rare. Most of the time, Server Controls are used for this
sort of thing. Without knowing your requirements, it isn't possible to
advise you as to the correct solution.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Daniel" <Da*****@vestry online.com> wrote in message
news:ui******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

Does anyone know if it is possible to put an aspx page inside of
another? OR run an aspx page and capture the output as a string and
then write this out to a page....

So for example say you have a page that takes an id number as a query
string and displays different things based on that id number.

If you were able to loop through running the aspx pages with id=100,
id=200, id=300 etc and on each loop capture the output as a string and
then response.write it out on the page this script was being executed,
the end result would be the page shown over and over again one after
the other but as if each had been run with a different id number?




Dec 30 '05 #7
Hi Daniel,
Kevin - Yes i had looked at repeaters but I have never used them before
and was not sure if they can handle absolutely positioned items, if i
understand right a repeater needs a template given to it, so i woul dhave
to pass in my full structure of my table layout but use the
databinder.eval where the vars would go. Is that right? If you can provide
some sample code on a very basic repeater that would help.
A Repeater will repeat whatever HTML is inside it, and whatever HTML is
rendered by Controls inside it. Looking at the ASP.Net object model, an
ASP.Net Page is an HttpHandler, which is also a Templated Control, and a
container for a WebForm, and/or other .Net Server Controls. Note that it is
also a Control. A Control renders HTML to an HttpHandler's
Response.Output Stream. So, you have 2 diffferent classes of Controls here.
One handles an HTTP Request. Both write HTML to an HttpHandler's
Response.Output Stream. You only need one HTTP Handler to handle a Request.
There is only one Response, and that belongs to the HttpHandler.

Let's take a look at your initial (ASP) solution to your requirements:
1) looped through the database retrieving all the orderids of open
orders
2) For each it found it then retrieved the sub parts of that order, e.g.
tin of beans £10, tin of tuna £5 etc
3) It then wrote this out building the complete page on the fly in a
table, putting in the company logo, address, delivery address....made
the invoice basically.
4) Once the first invoice is done I then created a page break (using
CSS) to force a new page and write the next invoice etc


So, breaking this down abstractly into a set of requirements, you have a
requirement to create a single HTML document that prints out as multiple
printer documents. You're fetching data from a database and populating an
HTML table with the data.
According to your OP, you're not building more than one page. You're adding
HTML blocks to a single web page, and using CSS page breaks to break it up
when printing, correct?

It is important to note that, while ASP.Net uses a fully-object-oriented and
highly-structured object model, under the hood, ASP and ASP.Net both do the
same thing: They handle HTTP Requests, perform server-side processing, and
render HTML to the Response object's output stream, which is a file stream.

I may be wrong here, but I think I detect a bit of confusion between the
word "page" in the context of a web page rendered by ASP or ASP.Net, and
"page" in the context of printing. It is important to distinguish between
them. A single HTML web page can (and often does) print out to many pages on
a printer. Forgive me if I'm wrong about your understanding regarding this.

Okay, so, how does the web page control where the printer pages break? Well,
there are 2 options: If no CSS page breaks are used, the printer will create
page breaks at points in the page where the remaining content does not fit
in the printed page, whatever its dimensions are. The printer knows the
dimensions of the printable page, and the dimensions of the web page, and
simply cuts it up wherever it happens to break. If CSS page breaks are used,
the printer will break and create a new page whenever it encounters one of
these breaks. Also, if the content between the CSS breaks is longer than the
printable area, the printer will chop this up too. So, if we want full
control over the pagination, we need to ensure that the HTML content between
the page breaks is smaller than the printable page size.

Putting it all together, you want to create a single HTML document from
multiple database records. This single HTML document will repeatedly render
HTML blocks that are smaller than the printable target area, and put CSS
Page breaks between them.

So, note that we haven't talked about having to render more than one ASP.Net
page; only that we need to break it up into repeating blocks, one for each
database record.

This is exactly what a Repeater Control does. It is like an "embedded"
template in a Page. The Repeater Template is databound to data in a data
source, such as a DataSet or DataTable. It will repeat its functional output
once per item in the data source. This could include style information, as
well as CSS Page breaks, in addition to the content of each invoice. Here
are some excellent references regarding Repeaters, using Templated Controls,
and DataBinding Expressions:

http://msdn.microsoft.com/library/de...vercontrol.asp
http://msdn.microsoft.com/library/de...edcontrols.asp
http://msdn.microsoft.com/library/de...evaltopic1.asp

As for your absolute positioning (thought I'd forgot?), There is no doubt a
CSS solution to your positioning problem. However, using absolute
positioning is not likely to be the solution. It may involve the judicious
use of HTML tables, with perhaps some relative positioning of the tables
themselves. The table can be used to keep everything inside it aligned
relatively within the table, and then use relative positioning to position
itself relative to the printed page (left, right, top, bottom).

BTW, you could also combine the use of a Repeater with a User Control in it,
as Peter suggested. The User Control would contain all the content you want
repeated, and be data-bound to each individual record via data binding. This
may not be necessary, depending upon your overall requirements
(extensibility, for example).

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Daniel" <Da*****@vestry online.com> wrote in message
news:eh******** *****@TK2MSFTNG P10.phx.gbl... Hi Kevin/Peter

Peter - User controls sounds ideal not sure how to sort the new page issue
with it tho, i could look into a way of padding it. So if i understand you
right i make a control that draws the invoice and take a var of orderid,
then just keep making new instances one after the other for each order id?
Sounds like a good solution

Kevin - Yes i had looked at repeaters but I have never used them before
and was not sure if they can handle absolutely positioned items, if i
understand right a repeater needs a template given to it, so i woul dhave
to pass in my full structure of my table layout but use the
databinder.eval where the vars would go. Is that right? If you can provide
some sample code on a very basic repeater that would help.

Either way thanks a million for both your responses.

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:OH******** ******@TK2MSFTN GP09.phx.gbl...
Hi Daniel,

Sounds like a Repeater Control to me. Have you looked into it?

The issue here is that an ASP.Net page is designed to render an entire
HTML document. While it can do otherwise, Server Controls are
specifically designed to render HTML *in* HTML documents. So, a Repeater
Control will render the same HTML over an over again, which it sounds
like you want to do.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Daniel" <Da*****@vestry online.com> wrote in message
news:eS******** *****@TK2MSFTNG P11.phx.gbl...
Hi Kevin,

Thank you for replying. A very long way of saying 'why do you want to do
that' but i will explain :)

I have posted this elsewhere in detail and had a few replies but its
difficult to explain so i will try again here.

I have made an invoice in old asp a while ago. It did the following:

1) looped through the database retrieving all the orderids of open
orders
2) For each it found it then retrieved the sub parts of that order, e.g.
tin of beans £10, tin of tuna £5 etc
3) It then wrote this out building the complete page on the fly in a
table, putting in the company logo, address, delivery address....made
the invoice basically.
4) Once the first invoice is done I then created a page break (using
CSS) to force a new page and write the next invoice etc

So once finished i had a load of invoices one after the other in a web
page, then i press print and out they come ready for dispatch.

With that in mind i now want to update that page to do the same task in
asp.net. I now have some new stationary, paper with a peel off label
attached.

So i now need the exact same thing achieved but with the exact position
of the delivery address to match with the label, in .net using absolute
positioning and the lovely interface this didnt take long and so i have
created my .net page to take an order id and create my invoice with
everything where it should be.

All make sense so far?

My problem is as with my original, i want it to now move onto the second
invoice, create a new page, and repeat....then to the net and so on.

I want to avoid making a page that writes out html tags like my
original asp page and builds the tables on the fly.

So i have looked at putting it all in a panel and then making a new
panel on the fly for the second invoice and placing this one on a new
page using my css break to break them apart on a new page. Problem is i
dont seem to be able to get the panel position programatically in order
to do this. (i also dont even know if that is a viable solution)

Another option which i was checking with my original question was to run
and embed the output of the single page that does work, changing the
querystring to each order id.....i agree it is very inefficient but it
would work. Then i could put my css page break between each output
stream.

I hope that all makes sense, if you can help i would be very grateful

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ex******** *****@TK2MSFTNG P12.phx.gbl...
Hi Daniel,

I think you need to back up a bit. You're talking about a solution, but
you haven't described the requirement. The solution is always based
first upon the requirement (in purely abstract terms), and upon the
available resources for satisfying the requirement.

The difference is that when you talk about puttting ASPX pages inside
one another, you're talking about a solution. The requirement would be
more along the lines of "I want to display a variable number of
database records on a page," or "I want to display one record on a
page, and have a link to the next page." It might include such
requirements as "The page body should look the same."

An ASPX Page is an HTTP Handler. There are situations in which you
might want to embed the output of one ASPX Page inside another, and you
can use Server.Transfer to accomplish this, but these situations are
relatively rare. Most of the time, Server Controls are used for this
sort of thing. Without knowing your requirements, it isn't possible to
advise you as to the correct solution.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Daniel" <Da*****@vestry online.com> wrote in message
news:ui******** ******@TK2MSFTN GP10.phx.gbl...
> Hi,
>
> Does anyone know if it is possible to put an aspx page inside of
> another? OR run an aspx page and capture the output as a string and
> then write this out to a page....
>
> So for example say you have a page that takes an id number as a query
> string and displays different things based on that id number.
>
> If you were able to loop through running the aspx pages with id=100,
> id=200, id=300 etc and on each loop capture the output as a string and
> then response.write it out on the page this script was being executed,
> the end result would be the page shown over and over again one after
> the other but as if each had been run with a different id number?
>
>
>
>



Jan 1 '06 #8
Hi Kevin,

A bit more detailed than i needed but it helped my understanding of the
repeater, and yes i did know the difference between a web page and a
printable page.

my original in asp i made by looping through the number of records and on
each building the table, filling in the data and then breaking the page with
css pagebreak.

it would seem the repeater does exactly this for you as you dont need to add
the loop just bind it.

Anyway i wanted to do it without the need to table it all, so keeping my
position absolute because it is so easy and quick in the design view to
position things.

Anyhow i took your advice and put my old asp fomrat into the repeater and it
works a treat.

Thanks for taking the time to reply so detailed, it really helped me
understand the repeater control.
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:u0******** ******@TK2MSFTN GP12.phx.gbl...
Hi Daniel,
Kevin - Yes i had looked at repeaters but I have never used them before
and was not sure if they can handle absolutely positioned items, if i
understand right a repeater needs a template given to it, so i woul dhave
to pass in my full structure of my table layout but use the
databinder.eval where the vars would go. Is that right? If you can
provide some sample code on a very basic repeater that would help.


A Repeater will repeat whatever HTML is inside it, and whatever HTML is
rendered by Controls inside it. Looking at the ASP.Net object model, an
ASP.Net Page is an HttpHandler, which is also a Templated Control, and a
container for a WebForm, and/or other .Net Server Controls. Note that it
is also a Control. A Control renders HTML to an HttpHandler's
Response.Output Stream. So, you have 2 diffferent classes of Controls here.
One handles an HTTP Request. Both write HTML to an HttpHandler's
Response.Output Stream. You only need one HTTP Handler to handle a Request.
There is only one Response, and that belongs to the HttpHandler.

Let's take a look at your initial (ASP) solution to your requirements:
1) looped through the database retrieving all the orderids of open
orders
2) For each it found it then retrieved the sub parts of that order,
e.g. tin of beans £10, tin of tuna £5 etc
3) It then wrote this out building the complete page on the fly in a
table, putting in the company logo, address, delivery address....made
the invoice basically.
4) Once the first invoice is done I then created a page break (using
CSS) to force a new page and write the next invoice etc


So, breaking this down abstractly into a set of requirements, you have a
requirement to create a single HTML document that prints out as multiple
printer documents. You're fetching data from a database and populating an
HTML table with the data.
According to your OP, you're not building more than one page. You're
adding HTML blocks to a single web page, and using CSS page breaks to
break it up when printing, correct?

It is important to note that, while ASP.Net uses a fully-object-oriented
and highly-structured object model, under the hood, ASP and ASP.Net both
do the same thing: They handle HTTP Requests, perform server-side
processing, and render HTML to the Response object's output stream, which
is a file stream.

I may be wrong here, but I think I detect a bit of confusion between the
word "page" in the context of a web page rendered by ASP or ASP.Net, and
"page" in the context of printing. It is important to distinguish between
them. A single HTML web page can (and often does) print out to many pages
on a printer. Forgive me if I'm wrong about your understanding regarding
this.

Okay, so, how does the web page control where the printer pages break?
Well, there are 2 options: If no CSS page breaks are used, the printer
will create page breaks at points in the page where the remaining content
does not fit in the printed page, whatever its dimensions are. The printer
knows the dimensions of the printable page, and the dimensions of the web
page, and simply cuts it up wherever it happens to break. If CSS page
breaks are used, the printer will break and create a new page whenever it
encounters one of these breaks. Also, if the content between the CSS
breaks is longer than the printable area, the printer will chop this up
too. So, if we want full control over the pagination, we need to ensure
that the HTML content between the page breaks is smaller than the
printable page size.

Putting it all together, you want to create a single HTML document from
multiple database records. This single HTML document will repeatedly
render HTML blocks that are smaller than the printable target area, and
put CSS Page breaks between them.

So, note that we haven't talked about having to render more than one
ASP.Net page; only that we need to break it up into repeating blocks, one
for each database record.

This is exactly what a Repeater Control does. It is like an "embedded"
template in a Page. The Repeater Template is databound to data in a data
source, such as a DataSet or DataTable. It will repeat its functional
output once per item in the data source. This could include style
information, as well as CSS Page breaks, in addition to the content of
each invoice. Here are some excellent references regarding Repeaters,
using Templated Controls, and DataBinding Expressions:

http://msdn.microsoft.com/library/de...vercontrol.asp
http://msdn.microsoft.com/library/de...edcontrols.asp
http://msdn.microsoft.com/library/de...evaltopic1.asp

As for your absolute positioning (thought I'd forgot?), There is no doubt
a CSS solution to your positioning problem. However, using absolute
positioning is not likely to be the solution. It may involve the judicious
use of HTML tables, with perhaps some relative positioning of the tables
themselves. The table can be used to keep everything inside it aligned
relatively within the table, and then use relative positioning to position
itself relative to the printed page (left, right, top, bottom).

BTW, you could also combine the use of a Repeater with a User Control in
it, as Peter suggested. The User Control would contain all the content you
want repeated, and be data-bound to each individual record via data
binding. This may not be necessary, depending upon your overall
requirements (extensibility, for example).

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Daniel" <Da*****@vestry online.com> wrote in message
news:eh******** *****@TK2MSFTNG P10.phx.gbl...
Hi Kevin/Peter

Peter - User controls sounds ideal not sure how to sort the new page
issue with it tho, i could look into a way of padding it. So if i
understand you right i make a control that draws the invoice and take a
var of orderid, then just keep making new instances one after the other
for each order id? Sounds like a good solution

Kevin - Yes i had looked at repeaters but I have never used them before
and was not sure if they can handle absolutely positioned items, if i
understand right a repeater needs a template given to it, so i woul dhave
to pass in my full structure of my table layout but use the
databinder.eval where the vars would go. Is that right? If you can
provide some sample code on a very basic repeater that would help.

Either way thanks a million for both your responses.

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:OH******** ******@TK2MSFTN GP09.phx.gbl...
Hi Daniel,

Sounds like a Repeater Control to me. Have you looked into it?

The issue here is that an ASP.Net page is designed to render an entire
HTML document. While it can do otherwise, Server Controls are
specifically designed to render HTML *in* HTML documents. So, a Repeater
Control will render the same HTML over an over again, which it sounds
like you want to do.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Daniel" <Da*****@vestry online.com> wrote in message
news:eS******** *****@TK2MSFTNG P11.phx.gbl...
Hi Kevin,

Thank you for replying. A very long way of saying 'why do you want to
do that' but i will explain :)

I have posted this elsewhere in detail and had a few replies but its
difficult to explain so i will try again here.

I have made an invoice in old asp a while ago. It did the following:

1) looped through the database retrieving all the orderids of open
orders
2) For each it found it then retrieved the sub parts of that order,
e.g. tin of beans £10, tin of tuna £5 etc
3) It then wrote this out building the complete page on the fly in a
table, putting in the company logo, address, delivery address....made
the invoice basically.
4) Once the first invoice is done I then created a page break (using
CSS) to force a new page and write the next invoice etc

So once finished i had a load of invoices one after the other in a web
page, then i press print and out they come ready for dispatch.

With that in mind i now want to update that page to do the same task in
asp.net. I now have some new stationary, paper with a peel off label
attached.

So i now need the exact same thing achieved but with the exact position
of the delivery address to match with the label, in .net using absolute
positioning and the lovely interface this didnt take long and so i have
created my .net page to take an order id and create my invoice with
everything where it should be.

All make sense so far?

My problem is as with my original, i want it to now move onto the
second invoice, create a new page, and repeat....then to the net and so
on.

I want to avoid making a page that writes out html tags like my
original asp page and builds the tables on the fly.

So i have looked at putting it all in a panel and then making a new
panel on the fly for the second invoice and placing this one on a new
page using my css break to break them apart on a new page. Problem is i
dont seem to be able to get the panel position programatically in order
to do this. (i also dont even know if that is a viable solution)

Another option which i was checking with my original question was to
run and embed the output of the single page that does work, changing
the querystring to each order id.....i agree it is very inefficient but
it would work. Then i could put my css page break between each output
stream.

I hope that all makes sense, if you can help i would be very grateful

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ex******** *****@TK2MSFTNG P12.phx.gbl...
> Hi Daniel,
>
> I think you need to back up a bit. You're talking about a solution,
> but you haven't described the requirement. The solution is always
> based first upon the requirement (in purely abstract terms), and upon
> the available resources for satisfying the requirement.
>
> The difference is that when you talk about puttting ASPX pages inside
> one another, you're talking about a solution. The requirement would be
> more along the lines of "I want to display a variable number of
> database records on a page," or "I want to display one record on a
> page, and have a link to the next page." It might include such
> requirements as "The page body should look the same."
>
> An ASPX Page is an HTTP Handler. There are situations in which you
> might want to embed the output of one ASPX Page inside another, and
> you can use Server.Transfer to accomplish this, but these situations
> are relatively rare. Most of the time, Server Controls are used for
> this sort of thing. Without knowing your requirements, it isn't
> possible to advise you as to the correct solution.
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> You can lead a fish to a bicycle,
> but it takes a very long time,
> and the bicycle has to *want* to change.
>
> "Daniel" <Da*****@vestry online.com> wrote in message
> news:ui******** ******@TK2MSFTN GP10.phx.gbl...
>> Hi,
>>
>> Does anyone know if it is possible to put an aspx page inside of
>> another? OR run an aspx page and capture the output as a string and
>> then write this out to a page....
>>
>> So for example say you have a page that takes an id number as a query
>> string and displays different things based on that id number.
>>
>> If you were able to loop through running the aspx pages with id=100,
>> id=200, id=300 etc and on each loop capture the output as a string
>> and then response.write it out on the page this script was being
>> executed, the end result would be the page shown over and over again
>> one after the other but as if each had been run with a different id
>> number?
>>
>>
>>
>>
>
>



Jan 9 '06 #9

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

Similar topics

4
14473
by: Julia Briggs | last post by:
I am struggling to create a PHP function that would take a specified image (JPG, GIF or PNG) from a link, and resize it down to a thumbnail so it will always fit in a 200x250 space. I am hoping not to have it inserted or read from a database to do this function. Can it be done & someone please help me?
36
9480
by: rbt | last post by:
Say I have a list that has 3 letters in it: I want to print all the possible 4 digit combinations of those 3 letters: 4^3 = 64 aaaa
20
2515
by: CHIN | last post by:
Hi all.. here s my problem ( maybe some of you saw me on other groups, but i cant find the solution !! ) I have to upload a file to an external site, so, i made a .vbs file , that logins to the site, and then i have to select the file to upload.. i used sendkeys.. and i worked perfect.. BUT ... the computer must be locked for security ( obviusly ) reazons.. so..i think this probable solutions to unlock the computer and run the...
7
2349
by: Andrzej | last post by:
Is it possible to call a function which name is given by a string? Let assume that I created a program which call some functions for example void f1(void), void f2(void), void f3(void). After some time, I added new function void f4(void).
2
3817
by: Bhupesh Naik | last post by:
This is a query regarding my problem to make a spell and grammar check possible in text area of a web page. We have aspx pages which are used to construct letters. The browser based screens provide text area where the user can insert big chunks of text and submit it all to the server paragraph by paragraph. The requirement is to do a Spell Check AND Grammar Check in the text area. I did look at lot of possible third
1
6961
by: AAA | last post by:
hi, I'll explain fastly the program that i'm doing.. the computer asks me to enter the cardinal of a set X ( called "dimX" type integer)where X is a table of one dimension and then to fill it with numbers X; then the computer asks me how many subsets i have (nb_subset type (integer)) then,i have to enter for every sebset the card, and then to fill it, we'll have a two tables , one called cardY which contains nb_subset elements,and every...
25
2554
by: Piotr Nowak | last post by:
Hi, Say i have a server process which listens for some changes in database. When a change occurs i want to refresh my page in browser by notyfinig it. I do not want to refresh my page i.e. every 5 seconds, i just want to refresh it ONLY on server change just like desktop applications do. The problem is that refreshing evry n seconds has to much impact on my web server. The refresh action should be taken only when something
4
7690
by: RSH | last post by:
Okay my math skills aren't waht they used to be... With that being said what Im trying to do is create a matrix that given x number of columns, and y number of possible values i want to generate a two dimensional array of all possible combinations of values. A simple example: 2 - columns and 2 possible values would generate: 0 0
7
3362
by: Robert S. | last post by:
Searching some time now for documents on this but still did not find anything about it: Is it possible to replace the entry screen of MS Office Access 2007 - that one presenting that default 'templates' (with that big graphic buttons) - with some sort of own HTML-Page? I could imagine, that somehow it is possible to change this construction (hopefully not hardcoded in MS-Acc07), like it is possible to edit the 'Fluent Ribbon'? If so...
14
2008
by: bjorklund.emil | last post by:
Hello pythonistas. I'm a newbie to pretty much both programming and Python. I have a task that involves writing a test script for every possible combination of preference settings for a software I'm testing. I figured that this was something that a script could probably do pretty easily, given all the various possibilites. I started creating a dictionary of all the settings, where each key has a value that is a list of the possible...
0
9454
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
10104
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
10038
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
9912
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...
0
8934
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, 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...
1
7460
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
6715
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
4007
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
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.