|
Hi.
I´ve been creating web pages for some years now, and been moving away from creating asp.net page-controls from codebehind because of the overhead they generate and the postback challenges you encounter. Instead I´ven been relying on javascript, jquery, old-school html elements and webservices, since they give me more elegant and light solutions.
The challenge I face now, is that it should be possible to construct a page based on a xml-setup file. The page design is luckily quite simple. It´s basically a vertical page with controls on top of each other.
I´m planning to create xml elements/types that define each control with it´s attributes. For an example a textbox with a css class, numeric text only value, which method to fire on textchanged, etc.. Or a button with a width, height, text, which (javascript?) method to fire upon click. Based on these types, I create the controls on the page.
My question is, should I create and insert these controls from codebehind, that means asp.net controls?
Or should I, for an example, build the dom in codebehind and let the javascript get the DOM from webservice, and then inject it on the page? Or what would be a good approach to this problem?
Thank you in advance
Kind regards,
Lars
|
|
|
|
|
I currently build main structures or containers in code behind via server controls on the server side because it's fast, and then use javascript to build the HTML inside the empty containers after a web service request to populate them on demand or if it's just simply needed.
On the Javascript side, I use createElement, I don't write "<>< >" out, I did that in my earlier days. Writing HTML in pure javascript is very time consuming, so I keep it limited now.
I don't know about your xml idea, still thinking about that, actually I don't get it.
But on the latter question, It's a balance between time to create, and functionality. I personally don't like the Microsoft Ajax toolkit, and I'm stopped using it completely now, replacing it with jquery.
|
|
|
|
|
Thanks alot for your answer.
Ok, so you build the page structure from codebehind, and the content controls with javascript/jquery.
My challenge is a little different though. What I meant with the xml thing, is that the whole site has a setup file, which defines the controls on the page. Like this:
<PageSetup>
<Control Type="TextBox" CssClass="test" PageOrder="1" Text="Default text in the textbox" />
<Control Type="Drowdown" CssClass="dropdownClass" PageOrder="2" >
<Item text="Dropdown item 1" Value="1000" />
<Item text="Dropdown item 2" Value="2000" />
</Control>
...
</PageSetup>
Hope that clearifies it a bit
I´ve started the project, and chosen to avoid the asp.net controls. So right now I build a long html string from codebehind, bases on the xml settings, and inject it on the page with jquery.
Any better idea?
Thanks alot for your time!
|
|
|
|
|
So what will be advantage of that solution against .aspx markup?
No more Mister Nice Guy... >: |
|
|
|
|