473,511 Members | 14,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create aspx in runtime

is it possible (how) to build a asp.net page on the fly?
i.e.: I have a db with the controls I want to add to it:
1. TextBox - name "ABC" - Text "CDE" - Left 10 - Top - 30
2. Button - name "BT1" - Text "TXT" - Left 30 - Top 100

I have the following issue...
I am trying to build a simple CRM tool... - I've done this before in VB
(Client-Server) - and I thought it would be great in asp.net (c#)...
so far - no problem...

one of the featurings of the system is to build the scripts (some admin
builds the layout of some scripting page - labels, checkboxes, textboxes).
The regular user has to fill it and the information has to be stored in a db.

if I build my own the scripts (aspx pages) - no problem...
but I do have to let this "admin" built it at runtime...
so he/she has to login, set the controls he/she wants to display, set their
position and the associated field to the db...

the only way I found (and I haven't tried it yet) is to take the compiler
within the server and compile every time the admin creates/changes something

--
Bruno Pimentel Machado
Software Engineer
Brazil - Sao Paulo
Nov 18 '05 #1
1 1839
Bruno, if I understand correctly, the solution is fairly simple.

Let's say your page is default.aspx?FormId=XXX where formId is the dynamic
form created by the admin, in the .aspx page you'd put a placeholder

<asp:placeholder id="formHolder" runat="Server" />

in codebehind you'd do something like (not actual code)

protected formHolder as System.Web.UI.PlaceHolder

Sub Page_Load
dim formId as integer = cint(Request.QueryString("formId")) 'error checks
need to be added
dim dt as datable = GetForm(formId)
for each row as DataRow in dt.rows
dim c as Control
select case cstr(row("Type")).ToUpper()
case "TEXTBOX":
c = new TextBox()
case "BUTTON"
c = new Button()
end select
c.style.add("position", "relative")
c.style.add("top", cstr(row("Top")))
c.style.add("top", cstr(row("Left")))
c.id = cstr(row("name"))
formHolder.controls.add(c)
next
End Sub

private function GetForm(formId as integer) as datatable
'Hit the database and popupate a Datatable for all the fields for the
given form
'I would expect the DT to have these columns: Type string, name string,
left int, top int
return datatable
end function
In other words, get each item, dynamically create them and add them to the
placeHolder. Now you can get more creative if you need to support, say a
label for each field, or if you have a dropdownlist or a radiobuttonlist and
you need to support multiple values (with perhaps a default selected
one)....all of that can be achieved by simply enriching your datatable or
adding datarelations (even better) and handing it in a similar way.

Karl

"Bruno Pimentel Machado" <Br******************@discussions.microsoft.com>
wrote in message news:5D**********************************@microsof t.com...
is it possible (how) to build a asp.net page on the fly?
i.e.: I have a db with the controls I want to add to it:
1. TextBox - name "ABC" - Text "CDE" - Left 10 - Top - 30
2. Button - name "BT1" - Text "TXT" - Left 30 - Top 100

I have the following issue...
I am trying to build a simple CRM tool... - I've done this before in VB
(Client-Server) - and I thought it would be great in asp.net (c#)...
so far - no problem...

one of the featurings of the system is to build the scripts (some admin
builds the layout of some scripting page - labels, checkboxes, textboxes).
The regular user has to fill it and the information has to be stored in a db.
if I build my own the scripts (aspx pages) - no problem...
but I do have to let this "admin" built it at runtime...
so he/she has to login, set the controls he/she wants to display, set their position and the associated field to the db...

the only way I found (and I haven't tried it yet) is to take the compiler
within the server and compile every time the admin creates/changes something
--
Bruno Pimentel Machado
Software Engineer
Brazil - Sao Paulo

Nov 18 '05 #2

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

Similar topics

10
1500
by: Shapper | last post by:
Hello, I am working on an ASP.NET / VB web site and I need to have 2 versions: In English and French. I could create two versions of the web site by duplicating all the pages. Is that the...
14
2453
by: Mark B | last post by:
Our webhost (www.usbusinessweb.net) had a W2K IIS5 server crash after a scheduled hard-boot occurred during a ms-security patch install overnight. They couldn't get the server working again so they...
4
10490
by: John Daly | last post by:
Does anyone know how to create an image (JPEG) from an HTTPResponse object? I am working on system that has a map pop up from our GIS department. I want create an image at runtime from this popup...
5
20111
by: ljlevend2 | last post by:
Is there any way to create a local server during runtime? For example, if you add an existing Web Site to a Solution from within Visual Studio (by right clicking the solution in the Solution...
13
2405
by: docschnipp | last post by:
Hi, I have a bunch of object derived from the same base class. They all share the same constructor with some parameters. Now, instead of using a large switch() statement where I call every...
5
1693
by: shapper | last post by:
Hello, In this moment I am creating all my aspx pages on my vb.code at runtime. It seems nonsense to have .aspx and .aspx.vb files in my projects. I am considering creating my pages on the...
7
1711
by: =?Utf-8?B?YW5kZXJzY2g=?= | last post by:
Hi It is possible to create an .exe file at runtime with .NET 2.0? I would like to create a .exe that should include: - an encrypted file - a simple winform to decrypt the included encrypted...
11
5343
by: Mark B | last post by:
I want to display a pre-designed graphical 'performance badge' on certain webpages (round, about 2cm diameter) next to a salesperson's details. I have a function,...
4
4155
by: Axel Dahmen | last post by:
Hi, I've created a few simple console tools. No .NET used at all, just STL. Now I want to just XCOPY them to another machine. But running them there yields a couple of errors in the application...
0
7148
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
7367
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
7430
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
7517
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...
1
5072
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...
0
4743
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...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3217
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
790
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.