473,394 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Execute a string of code as if it were a page

Hi,

I wondering if it is possible in asp.net to somehow execute a string
of code as if it were a page on the server. That is to say, if I
executed the following code which resided in an aspx page

<html>
<body>
<% Response.Write("Hi.") %>
</body>
</html>

the output would be

<html>
<body>
Hi
</body>
</html>

Is there some way I could execute the asp.net from above without it
being in an actual page? Can I send some server method a string and
get the output?

Thanks for any help,

Nick
Nov 18 '05 #1
2 1354
TJS
build the string , populate it with dynamic content and use,
response.write("mystring")

"nick" <ni**********@hotmail.com> wrote in message
news:30**************************@posting.google.c om...
Hi,

I wondering if it is possible in asp.net to somehow execute a string
of code as if it were a page on the server. That is to say, if I
executed the following code which resided in an aspx page

<html>
<body>
<% Response.Write("Hi.") %>
</body>
</html>

the output would be

<html>
<body>
Hi
</body>
</html>

Is there some way I could execute the asp.net from above without it
being in an actual page? Can I send some server method a string and
get the output?

Thanks for any help,

Nick

Nov 18 '05 #2
Hey Nick,
Not directly...

What you can do though is create a file on disk, then use Server.Execute()
to 'run' that page. You can delete it when you're done.

IOW:

Take your string
dump to file with ASPX extensino
Server.Execute() to the page with an HtmlTextWriter
Return retrieve the HtmlTextWriter and the result string
Delete the page you created

Be aware though that this causes memory to be used as this new class (the
ASPX) page is created and compiled into an assembly and laoded. If you did
this a lot during processing you'd eat up memory really quickly.

What you should do instead is build a few generic pages that you can use
over and over and do some sort of processing inside those pages that might
be more dynamic.
+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/webblog/
----------------------------------
Making waves on the Web
"nick" <ni**********@hotmail.com> wrote in message
news:30**************************@posting.google.c om...
Hi,

I wondering if it is possible in asp.net to somehow execute a string
of code as if it were a page on the server. That is to say, if I
executed the following code which resided in an aspx page

<html>
<body>
<% Response.Write("Hi.") %>
</body>
</html>

the output would be

<html>
<body>
Hi
</body>
</html>

Is there some way I could execute the asp.net from above without it
being in an actual page? Can I send some server method a string and
get the output?

Thanks for any help,

Nick

Nov 18 '05 #3

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

Similar topics

6
by: JT | last post by:
is it possible to somehow "jump out of" an ASP page that is executed from another page via the Server.Execute method? on the page being executed i have several instances where i need to stop the...
2
by: Elie Grouchko | last post by:
Hi All I am using Application.lock to protect a reference to a COM+ object while calling Server.Execute() to another ASP page. I am doing this to pass the object's reference to the other page,...
3
by: Chris | last post by:
I have yet to understand or get a response on the issue I'm having. I'm taking an asp web application and migrating it from Windows 2K to 2003. I have the new website location (2003) settings...
4
by: Paul | last post by:
Hello, I tried to execute a button on an aspx webpage using WebRequest, but it failed. When posting data as if I did a login (see code), I just receive the login page, instead of the page I...
4
by: Chris | last post by:
I posted this in the C# language group, then thought it might be more appropriate in this group. I would not cross-post except I want the answer so badly. I built small C# Web and Web Service...
3
by: Sophos | last post by:
Hi, I have a basic aspx page, in the Page_Init procedure I have a server.execute of another aspx page that adds some html code to my first page. However it also adds a control (an htmlimage),...
2
by: Dune | last post by:
I'm trying to execute an aspx page by calling Server.Execute. The aspx page I'm trying to execute is in a different web app from the aspx page containing the Server.Execute statement. A slightly...
4
by: Ian Kelly | last post by:
Hi All, I have an .net form that is split into two frames. The left frame has a tree that displays a list of all the customers. The right frame displays the appropriate clients information. ...
0
by: Brian | last post by:
I'm using Server.Execute to decide at run-time which .aspx page to use to format a mail message. Using a StringWriter, I call Server.Execute on the page that does the formatting, then snag the text...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.