DotVVM code only component dont generate HTML structure correctly -
i have own component treeview menu , want generate html structure this.
<a href> <span class="something"> <i class="icon"></i> </span> </a>
here code generate structure menu
public void databinditem(dotvvmcontrol parent, adminmenulistdto item, idotvvmrequestcontext context) { var li = new htmlgenericcontrol("li"); if (item.hascategories) { //holder pro ikonu (šipku ukazující možnost rozbalení menu) var iclasscontainer = new htmlgenericcontrol("span"); iclasscontainer.attributes.add("class", "pull-right-container"); //ikona pro šipku ukazující možnost rozbalení menu var iclass = new htmlgenericcontrol("i"); iclass.attributes.add("class", "fa fa-angle-left pull-right"); li.attributes.add("class", "treeview expandable"); if (!string.isnullorempty(item.name)) { var ahref = new htmlgenericcontrol("a"); ahref.innertext = item.name; ahref.attributes.add("class", "tree-toggler nav-header"); ahref.attributes.add("id", item.id.tostring()); // add <a href> <li> li.children.add(ahref); // add <span> container <a href> ahref.children.add(iclasscontainer); // add <i class> <span> contains icon iclasscontainer.children.add(iclass); } var childcontainer = new htmlgenericcontrol("ul"); childcontainer.attributes.add("class", "nav nav-list tree"); childcontainer.attributes.add("style", "display:none;"); foreach (var child in item.assignedtomenuitem) { databinditem(childcontainer, child, context); } li.children.add(childcontainer); } else { li.attributes.add("style", "treeview"); if (item.routename != null) { var routelink = new routelink(); routelink.routename = item.routename; routelink.text = item.name; routelink.attributes.add("class", "js_isroute_" + item.id.tostring()); routelink.attributes.add("id", item.id.tostring()); li.children.add(routelink); } } parent.children.add(li); }
problem whole structure not rendered in view, see this. <a href>
tag should contains span
, i
.
my structre not rendered correctly in debug mode in vs in component see generated correctly. wrong?
it's because innertext
property works same way works in classic html. replaces children inside element.
Comments
Post a Comment