Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Building DOM from xml - asp.net controls, or html controls?

Building DOM from xml - asp.net controls, or html controls?

Scheduled Pinned Locked Moved ASP.NET
javascripthtmlquestioncsharpcss
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lvq684
    wrote on last edited by
    #1

    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

    J N 2 Replies Last reply
    0
    • L lvq684

      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

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      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.

      L 1 Reply Last reply
      0
      • L lvq684

        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

        N Offline
        N Offline
        n podbielski
        wrote on last edited by
        #3

        So what will be advantage of that solution against .aspx markup?

        No more Mister Nice Guy... >: |

        1 Reply Last reply
        0
        • J jkirkerx

          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.

          L Offline
          L Offline
          lvq684
          wrote on last edited by
          #4

          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!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups