プログラムでHTML要素を追加します
-
10-12-2019 - |
質問
私はそれがとても簡単な質問であると思いますが、私はただそれに立ち往生しています。
私のSharePoint 2010 Portalのカスタムページを開発しています。私の.aspxページにボタン(または他の要素)を追加する必要があります。
<input type="button" id="btnID" onclick="window.location.href='/CustomPage.aspx'" value="GO!" />
.
CodeBehindからそれをやろうとしました:
System.Web.UI.WebControls.Button button = new System.Web.UI.WebControls.Button();
button.OnClientClick = "window.location.href='/CustomPage.aspx'";
button.ID = "btnID";
button.Text = "GO!";
IVersionedContent9.Controls.Add(button);
.
しかし、私はページ上でこれを取得します:
<input type="submit" name="ctl00$PlaceHolderMain$UIVersionedContent9$btnID" value="GO!" onclick="window.location.href='/CustomPage.aspx';WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$PlaceHolderMain$UIVersionedContent9$btnID", "", true, "", "", false, false))" id="ctl00_PlaceHolderMain_UIVersionedContent9_btnID" />
.
私はクラスによくわからないが、他のものが間違っているかもしれません...
追加の値を指定せずに、ページに単純なHTML(ASP.NETではなく)ボタンを追加できますか?
事前にありがとう!
解決
you can do Response.Write, or you can use asp:Literal.
var ltlCnt = new LiteralControl();
string divStart = @"<div>";
ltlCnt.Text += divStart;
string divEnd = @"</div>";
ltlCnt.Text += divEnd;
this.[divOnPage].Controls.Add(ltlCnt);
所属していません sharepoint.stackexchange