我被分配到某个项目的web部分.这个项目有两个部分,窗口和web.在窗口部分,用户可以创建自己的自定义模板,如visual studio IDE,你可以添加表格和其他控件.然后,我们保存这个模板包含xml文件中的数据.我的职责是从这个xml文件中读取并创建webform.对于Web部件,只显示从窗口部件创建的信息.我们的xml文件格式如下所示.对于Web部件,我们使用asp.net mvc在c#.net中开发.
<Object type="System.Windows.Forms.Form">
<Object type="System.Windows.Forms.Label">
<Property name="Name">lblCity</Property>
<Property name="Text">City</Property>
</Object>
<Object type="System.Windows.Forms.TextBox">
<Property name="Name">txtCity</Property>
<Property name="Text">England</Property>
</Object>
<Object type="System.Windows.Forms.Label">
<Property name="Name">lblNRIC</Property>
<Property name="Text">NRIC</Property>
</Object>
<Object type="System.Windows.Forms.TextBox">
<Property name="Name">txtNRIC</Property>
<Property name="Text">ABC01234</Property>
</Object>
<Object type="System.Windows.Forms.RadioButton">
<Property name="Name">RadioButton1</Property>
<Property name="Text">OptionA</Property>
</Object>
<Object type="System.Windows.Forms.CheckBox">
<Property name="Name">CheckBox1</Property>
<Property name="Text">Yes</Property>
</Object>
<Object type="System.Windows.Forms.CheckBox">
<Property name="Name">CheckBox2</Property>
<Property name="Text">No</Property>
</Object>
<SampleDataSet>
<SampleTable>
<TableName>Sample1</TableName>
<ProductName>ABC</ProductName>
<Price>100</Price>
<Qty>10</Qty>
<Amount>1000</Amount>
</SampleTable>
<SampleTable>
<TableName>Sample2</TableName>
<ProductName>DEF</ProductName>
<Price>200</Price>
<Qty>20</Qty>
<Amount>4000</Amount>
</SampleTable>
<SampleTable>
<TableName>Sample3</TableName>
<ProductName>GHK</ProductName>
<Price>300</Price>
<Qty>30</Qty>
<Amount>9000</Amount>
</SampleTable>
</SampleDataSet>
</Object>
Run Code Online (Sandbox Code Playgroud)
我们知道它不应该像窗口部分一样创建Web表单,但是,我们确实需要它.那么,我如何解决我的问题?我可以使用xml serilization吗?请通过一些例子给我正确的方法.
问候
韩
您可以使用XSLT将此XML转换为XHTML.此外,您可以从MVC ActionResult类继承自己的XMLBasedFormResult,并使用C#在ExecuteResult方法中生成表单HTML(例如,使用LinqToXML).
| 归档时间: |
|
| 查看次数: |
2619 次 |
| 最近记录: |