将 html 添加到 CreateChildControls() 方法
我在 CreateChildControls() 方法中的 web 部件中使用 MOSS 2007 我有下面的代码:
protected override void CreateChildControls()
{
base.CreateChildControls();
Panel myPanel = new Panel();
myPanel.ID = "SelectionPanel";
this.Controls.Add(myPanel);
this.myGridView = new GridView();
createMyGridView(ref myGridView);
myPanel.Controls.Add(myGridView);
this._btnUpdate = new Button();
this._btnUpdate.Text = "Update";
myPanel.Controls.Add(_btnUpdate);
this._btnUpdate.Click += new EventHandler(_btnUpdate_Click);
}
我的问题是如何插入 html,以便我可以在这些控件周围包裹一个 div,没有< /strong> 使用 RenderWebPart() 方法。
我正在尝试实现此目标,因为我不想使用 id 将是自动生成的客户端 ID 的面板。
非常感谢,
I'm using MOSS 2007 in my webpart within my CreateChildControls() method I have the code below:
protected override void CreateChildControls()
{
base.CreateChildControls();
Panel myPanel = new Panel();
myPanel.ID = "SelectionPanel";
this.Controls.Add(myPanel);
this.myGridView = new GridView();
createMyGridView(ref myGridView);
myPanel.Controls.Add(myGridView);
this._btnUpdate = new Button();
this._btnUpdate.Text = "Update";
myPanel.Controls.Add(_btnUpdate);
this._btnUpdate.Click += new EventHandler(_btnUpdate_Click);
}
My question is how do insert html so I can wrap a div around these controls, without using the RenderWebPart() method.
I am trying to acheive this because i dont want to use a panel whose id will be an autogenerated client id.
Many Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不确定是否有某种原因这不适用于 Web 部件,但这似乎对 Web 用户控件有用:
I'm not sure if there's some reason this wouldn't work for a webpart, but this seems to do the trick for a web user control:
Panel
呈现为。试试这个:
Panel
render as<div>
. Try this:我正在处理类似的事情,我想将新的 SP 2013“+ 添加新公告”放入我的自定义 Web 部件中。
我尝试了这个,并且有效,但我不知道这是否是一个好方法。基本上你可以把任何html放在我发现的litteralcontrol中...
请告诉我是否有更好的方法来发布“原始自定义”html。
I'm working with something similar, and I wanted to put the new SP 2013 " + add new announcement" in my custom webpart.
I tried this, and it worked, but I dont know if it's a good way to do it. Basically you can put whatever html in a litteralcontrol I found out...
Please tell me if there is a better way of posting "raw custom" html.