-
Dom + Asp
Hello,
I want to make a DOM file with the content of a form (including
the webcontrols I want to use and the webcontrol sources) Is this possible with DOM?
Then I want to make an aspx file to read the DOM file and build
a dynamic webform. Then I want to save te content (data of the form) as a XML file.
My question : Is it possible to make dynamic forms in ASP.NET by
using the DOM ?
Greeting,
Krol
-
There is no Document Object Model for aspx pages. ASP is by nature already a dynamic system. So i dont know what you are trying to do beyond what ASP.NET already does.
-
dom + asp
First of all thanks for your reaction.
Perhaps I have to explain my question a little more :
I want to 'load' controls and control events dynamic
into an asp form.
I thought that DOM might by of use, but are there other
ways to load controls in a dynamic way into an asp form?
greetings,
Krol
-
yeah. in the page_load event for the aspx page, you can dynamically load controls. This may not 100% correct, but it might get you started
Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim btn As New System.Web.UI.WebControls.Button()
btn.Text = "Yo"
Form1.Controls.Add(btn)
End Sub
-
thanks ,
That is the information that I need!
Can I also add the control at a specific location?
greetings,
Krol
-
if you are using the GridLayout you can use style to specify postioning
like
btn.Style="Z-INDEX: 101; LEFT: 274px; POSITION: absolute; TOP: 145px"
-
You also may be able to use placeholder controls to control layout if you want. And instead of using Form1.Controls.Add(), if your using VB.Net, you should use Me.Controls.Add() I believe. This way if you change your form name at a later time, you don't have to go through your code and change all the form names. If you use C#, use this.Controls.Add()
Good luck.
-
problem is, does Me/this refer to the Page object or the HTML form object?
-
Both, at least from my experience.
Look at the code change when you add a server control on the form. There is a instance of it created in the code also. They are mixed together pretty well.
I have used this.Controls.Add() in my C# code a lot so far. No problems yet.
-
Here, in the page load even of a blank page, put this in (C#):
LiteralControl lc = new LiteralControl("Hello");
this.Controls.Add(lc);
Or VB.Net (might not be exact on the dim statement):
Dim lc As LiteralControl = New LiteralControl("Hello")
Me.Controls.Add(lc)