By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,543 Members | 2,085 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,543 IT Pros & Developers. It's quick & easy.

Is this possible...

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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*****@vestryonline.com> wrote in message
news:ui**************@TK2MSFTNGP10.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

P: n/a
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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ex*************@TK2MSFTNGP12.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*****@vestryonline.com> wrote in message
news:ui**************@TK2MSFTNGP10.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

P: n/a
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*****@vestryonline.com> wrote in message
news:eS*************@TK2MSFTNGP11.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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ex*************@TK2MSFTNGP12.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*****@vestryonline.com> wrote in message
news:ui**************@TK2MSFTNGP10.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

P: n/a
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*****@vestryonline.com> wrote in message
news:eS*************@TK2MSFTNGP11.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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ex*************@TK2MSFTNGP12.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*****@vestryonline.com> wrote in message
news:ui**************@TK2MSFTNGP10.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

P: n/a
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*****@vestryonline.com> wrote in message
news:eS*************@TK2MSFTNGP11.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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ex*************@TK2MSFTNGP12.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*****@vestryonline.com> wrote in message
news:ui**************@TK2MSFTNGP10.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

P: n/a
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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:OH**************@TK2MSFTNGP09.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*****@vestryonline.com> wrote in message
news:eS*************@TK2MSFTNGP11.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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ex*************@TK2MSFTNGP12.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*****@vestryonline.com> wrote in message
news:ui**************@TK2MSFTNGP10.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

P: n/a
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.OutputStream. So, you have 2 diffferent classes of Controls here.
One handles an HTTP Request. Both write HTML to an HttpHandler's
Response.OutputStream. 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*****@vestryonline.com> wrote in message
news:eh*************@TK2MSFTNGP10.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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:OH**************@TK2MSFTNGP09.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*****@vestryonline.com> wrote in message
news:eS*************@TK2MSFTNGP11.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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ex*************@TK2MSFTNGP12.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*****@vestryonline.com> wrote in message
news:ui**************@TK2MSFTNGP10.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

P: n/a
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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:u0**************@TK2MSFTNGP12.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.OutputStream. So, you have 2 diffferent classes of Controls here.
One handles an HTTP Request. Both write HTML to an HttpHandler's
Response.OutputStream. 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*****@vestryonline.com> wrote in message
news:eh*************@TK2MSFTNGP10.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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:OH**************@TK2MSFTNGP09.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*****@vestryonline.com> wrote in message
news:eS*************@TK2MSFTNGP11.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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ex*************@TK2MSFTNGP12.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*****@vestryonline.com> wrote in message
> news:ui**************@TK2MSFTNGP10.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 discussion thread is closed

Replies have been disabled for this discussion.