开发者

Configurable Web UI ASP.MVC

I am interested in building configurable ASP.NET MVC 3 UI application, by that I mean setting all UI element properties and attributes throughout XML configuration ( which can be edited with some other UI ) I have searched on Google for some platform, pattern, or common approach that leads to this goal and I did not found much.

  • My question i开发者_开发问答s how to read XML and render HTML elements, does it go via JavaScript ( jQuery )?
  • What is the best html naming and nesting strategy? ( I know this is not real question, but in circumstances that some pattern is necessary for easier elementtraversing )
  • Is there any code that I can reuse for this need?

Thanks.


It's hard to tell exactly what you are looking for.

If the XML is the data that you want to show, some options:

  • Use a XSLT to transform the XML into Html
    • Depending on your target users, you can even let the browser do it by assigning a XSLT in the XML you hand over to the browser. Returning XML directly to the browser instead of HTML or a ViewResult.
    • Another way is to apply the transformation in the action method and return it as a string (instead of returning a ViewResult).
    • Another alternative is to implement a XmlActionResult. You'll find that implementing Action Results is simple in asp.net MVC. On your controller you return a XmlActionResult with the data you want to show. The XmlActionResult applies the XSLT transformation.
    • Use custom code to transform the XML into Html. As with the XSLT transformation, you can do this either directly in the action method (by calling a common method you define elsewhere) or by defining your own action result.

If the XML is not the data, but only how you want to show whatever is in the model:

  • You are pretty much defining a ViewEngine. You are looking to define your view in xml instead of aspx, razor or whatever other language. If you roll your own it will be limited, if you use a third party (if you do find it) you'll have to deal with the language it is defined with.
  • You can combine Dynamic Data with asp.net MVC. I'm not sure if the control can be used in an asp.net MVC View, but is worth a shot searching about it.
  • You can use the DisplayFor methods in the View and define templates for all the simple types. Combine that with some helpers you define, and you can apply whatever configuration you have to the fields (even if that is not to show anything for it).


You can refer to the blog based on implementing XSLT View Engine

MVCDynamicForms is a good option you can consider

XSLTViewEngine is also you can consider if you are interested in XML to convert to HTML along with XSLT.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜