简体   繁体   中英

ASP.NET MVC2 - Dynamic Page Creation

I am kind of new to the world of ASP.NET (especially MVC), I am trying to build up a page based on the configuration below:

   <headInput>
    <defaultColumns>
      <column name="Shift" validation="" unit="" required="" />
      <column name="Level" validation="" unit="" required="" />
      <column name="Value" validation="" unit="" required="" />
      <column name="Time" validation="" unit="" required="" />
    </defaultColumns>
    <additionalCols1>
      <column name="Rate" validation="" unit="" required="" />
    </additionalCols1>
    <additionalCols2>
      <column name="Online" validation="" unit="" required="" />
      <column name="Type" validation="" unit="" required="" />
    </additionalCols2>
   </headInput>

I have been trying to understand on how I can use the above configuration to generate labels as columns and then generate the row with data in columns.

I tried looking at many examples but haven't been able to figure out if it is even possible or not. Any help would be appreciated.

Thanks.

I'm not sure what you're trying to do or what schema you're using in the example above, but my feeling is that you should be using HTML tables for this:

http://www.w3schools.com/html/html_tables.asp

http://www.w3.org/TR/html4/struct/tables.html

Tables are defined in rows, not columns, first with the heading row ( then the data rows then the table data .

Also look at the colspan attribute and the rowspan attribute which I think you'll need for this - lets columns span more than one row and rows span more than one column.

Also if you're learning MVC why are you using a 2 year old version?? MVC3 was released over a year ago and MVC 4 is in beta with a go-live license. We're using MVC 4 to develop a web based stock trading application and its solid as a rock.

There's an example of building an HTML table using MVC at http://www.asp.net/mvc/tutorials/older-versions/models-(data)/displaying-a-table-of-database-data-cs (scroll to the bottom to see the MVC view) Its basically HTML with some server tags for pulling the data from the model. That's how MVC is - very different from webforms where you'd have server controls generating HTML for you.

Looks like you need to generate HTML based on the XML input. You can use XSLT to do that.

Your MVC model should provide the XML and the View should use the XSLT to convert it to the HTML

here are few links which might be helpful -

http://www.htmlgoodies.com/beyond/xml/converting-xml-to-html-using-xsl.html

http://www.4guysfromrolla.com/webtech/081300-2.shtml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM