如何将 ascx 控件替换为 html 中的字符串标记?
我想创建一个动态 html 模板。
这是我的html
<div id="Detail_Container">
<div>Gallery 1</div>
<load_gallery>G6</load_gallery>
<div>Gallery 2</div>
<load_gallery>G7</load_gallery>
</div>
我对此进行了尝试:控件正在渲染,但我的图像未加载到控件中。
StringBuilder sb = new StringBuilder();
HtmlTextWriter textWriter = new HtmlTextWriter(new StringWriter(sb));
UserControl objControl = (UserControl)LoadControl(inControlPath);
objControl.GalleryId = "G5";
if (objControl != null)
objControl.RenderControl(textWriter);
string controlstr = tw.ToString();