简体   繁体   English

ASP.NET MVC2-动态页面创建

[英]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: 我是ASP.NET(尤其是MVC)领域的新手,我正在尝试根据以下配置建立一个页面:

   <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: 在上面的示例中,我不确定您要做什么或正在使用什么架构,但是我的感觉是您应该为此使用HTML表:

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

http://www.w3.org/TR/html4/struct/tables.html 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 . 表是按行而不是列定义的,首先是标题行(然后是数据行,然后是表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. 还要查看我认为您需要的colspan属性和rowspan属性-让列跨越一排以上,而行跨越多于一列。

Also if you're learning MVC why are you using a 2 year old version?? 另外,如果您正在学习MVC,为什么要使用2岁的版本? MVC3 was released over a year ago and MVC 4 is in beta with a go-live license. MVC3于一年多以前发布,MVC 4处于beta版,并具有正式许可证。 We're using MVC 4 to develop a web based stock trading application and its solid as a rock. 我们正在使用MVC 4来开发基于Web的股票交易应用程序,并且它的坚固如磐石。

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. http://www.asp.net/mvc/tutorials/older-versions/models-(data)/displaying-a-table-of-database-data-cs中有一个使用MVC构建HTML表的示例(滚动到底部以查看MVC视图)。它基本上是HTML,带有一些服务器标签,用于从模型中提取数据。 That's how MVC is - very different from webforms where you'd have server controls generating HTML for you. 这就是MVC的方式-与您需要服务器控件为您生成HTML的Web表单有很大不同。

Looks like you need to generate HTML based on the XML input. 看起来您需要根据XML输入生成HTML。 You can use XSLT to do that. 您可以使用XSLT来做到这一点。

Your MVC model should provide the XML and the View should use the XSLT to convert it to the HTML 您的MVC模型应提供XML,而View应使用XSLT将其转换为HTML

here are few links which might be helpful - 这里有一些链接可能会有所帮助-

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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