[英]Sharepoint Custom text Web part Property
用戶在Web部件屬性中輸入自定義文本時。 它將顯示在窗體上。
這是Web部件屬性的代碼,它位於testTextWebPart.ascx.cs上
public partial class testTextWebPart: WebPart
{
private string _customtxt;
[WebBrowsable(true),
Category("Miscellaneous"),
Personalizable(PersonalizationScope.Shared),
WebDisplayName("Enter some text")]
public string CustomTextProp
{
get
{
return _customtxt;
}
set
{
_customtxt = value;
}
}
我需要在表單上顯示文本。此頁面為testTextWebPart.ascx
<script type="text/javascript">
function NAME() {
var ctx = new SP.ClientContext.get_current();
var webURL = ctx.get_url;
var newFormURL = window.location.protocol + '//' + window.location.host + webURL + '/Lists/Testpage/NewForm.aspx';
var options = SP.UI.$create_DialogOptions();
options.title = 'PAGE TITLE';
options.url = newFormURL;
SP.UI.ModalDialog.showModalDialog(options);
}
我需要在這里顯示它。 這是在我的控制模板文件夾中,此頁面為testText.ascx
<div id="divForm" runat="server" style="width:400px; margin-left:auto; margin-right:auto; margin-top:10px;">
<div style="margin-bottom:10px;"> DISPLAY HERE </div>
我需要獲取用戶通過webpart屬性輸入的文本,然后在用戶單擊新表單時將其顯示在表單上。
您可以只將此方法添加到您的代碼中:
protected override void CreateChildControls()
{
base.CreateChildControls();
LiteralControl message = new LiteralControl();
message.Text = CustomTextProp;
Controls.Add(message);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.