adding web pages Dynamically to compiled Codebehind

W

Wardeaux

All,
Wanting to find a way to create web pages to add to my website without
having to recompile the codebehind everytime I want to add a new one...

Here's the deal:
I have a web app that takes work orders for 7 different items, each item
gets 1 page for input specs. All works well. I want to add a new item. I
do not want to recompile and redistribute my app everytime just to add a new
input page. Can ASPX resources be compiled into a DLL that I can easily pull
in and use and/or replace without recompiling the main app? Any other
suggestions?
MTIA
wardeaux
 
H

Hermit Dave

visual studio add an attribute to @Page - CodeBehind. this specifies the
codebehind file.
if codebehind is replaced with a src and if the files are then uploaded the
uploaded new file will be automatically compiled.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
 
I

i. Wiin

Why not dynamically pull the work order items from a xml file (or other data
store such as a database), then have ONE common page that asks for input
specs (this page can be dynaically created from the data in the datastore at
run-time), so all you have to do is add new entries to the datastore. Build
a little admin page that allows you to input new items into the datastore.
 
W

Wardeaux

i Wiin
So what you're saying is put a "definition" of the input page controls in an
XML doc, then just load the "definition" from the XML into a generic page
that knows how to read the "Definitions" and create the appropriate webpage?
Cool... I've not done any XML programming, is there a sample or article I
could look at that would demonstrate this technique? Sounds like exactly
what I need...
MTIA
wardeaux
 
I

i. Wiin

So then are you saying .NET is smart enough to know that the .dll in the bin
directory is outdated and will recompile it when a .vb or .cs file has been
updated?
 
H

Hermit Dave

the compiled file in the bin file was created by vs.net.
the framework does not need the compilation. the moment a new file is
requested (which was not previously present or was modified).. the framework
compiles the files.
from framework overview from msdn
Compiled execution. ASP.NET is much faster than classic ASP, while
preserving the "just hit save" update model of ASP. However, no explicit
compile step is required! ASP.NET will automatically detect any changes,
dynamically compile the files if needed, and store the compiled results to
reuse for subsequent requests. Dynamic compilation ensures that your
application is always up to date, and compiled execution makes it fast.
http://msdn.microsoft.com/asp.net/technologyinfo/overview/default.aspx

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
 
H

Hermit Dave

i unfortunately dont use this mechanism.. prefer to do a complete upload. I
have at times modified aspx files to a great extent... and in the next
request it was compiled and rendered properly. Good luck with that...

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
 
G

Guest

One easy way: use Dataset.Readxml and Dataset.Writexml. Populate your
dataset in code one-time with the schema and data, then do writexml to get
your xml file. If you look at the resulting xml file you'll see it's easy to
add your rows by hand later. When your programs runs for real, use readxml to
create your dataset from the xml file, then you'll traverse that dataset and
build your controls on the fly.

One other way, depending on how wildly different the geometry of the input
controls is for each item: You could create a user control for each item, use
a naming convention to match user control to item id, and then use
"loadcontrol" to load the appropriate user control at run time.

Going the data-driven way is a whole lot cleaner and definitely a
best-practice, but sometimes the templates are so different for each you'll
spend longer trying to create the "generic" mother of all data structures to
handle each variation than just banging out a few controls. Mostly depends on
how many item variations you expect to have and how different the geometry of
the screens is.

Bill
 
W

Wardeaux

Dave,
this is good... I've loaded a new aspx page which displays correctly
without compiling, but the code behind does not seem to work (just setting a
value in a text box on button press)... any tricks to get this to work?
thanks!
wardeaux
 
W

Wardeaux

Dave,
thank you so much!! You have been super helpful... it's working great!! I
just have one last issue... I create my ASPX form in VisualStudio, and set
the "src" attribute save and it loads fine, but when I reload the project I
get a Visual Studio error that "Src" is not supported in the @Page
attributes and the "Design" view is not loaded... is there a way to get
around this? I really like being able to design/program my page in VS and
then just upload to website for distribution, but this error doesn't let me
view the "Design" screen so that I can add new controls etc... any other
hints?
wardeaux
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top