0
我創建了一個簡單的視覺web部件與該HTML簡單的視覺web部件時,不呈現控件
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="LinkButton.ascx.cs" Inherits="xx.xxxxDMS.WebParts.VisualWebParts.LinkButton.LinkButton" %>
<script type="text/javascript">
function OpenModalPopup(pageUrl) {
var options = { url: pageUrl, width: 900, height: 300 };
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
}
</script>
<asp:LinkButton ID="LnkButton" runat="server"></asp:LinkButton>
然後,在後面的代碼,我加入3-性質。在我用文本鏈接和url編輯屬性後,我沒有看到LinkButton呈現。我錯過了什麼嗎?請注意,它的SP 2013
但我注意到,有我在控制模板文件夾customwebpart沒有ASCX文件,所以我想在2013年會有改變?
using System;
using System.ComponentModel;
using System.Web.UI.WebControls.WebParts;
namespace xx.SP.xx.WebParts.VisualWebParts.LinkButton
{
[ToolboxItemAttribute(false)]
public partial class LinkButton : WebPart
{
private string _LinkText;
private Uri _Link;
private Boolean _OpenModal;
[WebBrowsable(true), WebDisplayName("LinkText"), WebDescription("Text for the link"),
Personalizable(PersonalizationScope.Shared), Category("xx - xx"),
System.ComponentModel.DefaultValue("")]
public string LinkText
{
get { return _LinkText; }
set { _LinkText = value; }
}
[WebBrowsable(true), WebDisplayName("Link"), WebDescription("Link"),
Personalizable(PersonalizationScope.Shared), Category("xx- xx"),
System.ComponentModel.DefaultValue("")]
public Uri Link
{
get { return _Link; }
set { _Link = value; }
}
[WebBrowsable(true), WebDisplayName("OpenModal"), WebDescription("OpenModal"),
Personalizable(PersonalizationScope.Shared), Category("xx- xx"),
System.ComponentModel.DefaultValue("")]
public Boolean OpenModal
{
get { return _OpenModal; }
set { _OpenModal = value; }
}
// Uncomment the following SecurityPermission attribute only when doing Performance Profiling on a farm solution
// using the Instrumentation method, and then remove the SecurityPermission attribute when the code is ready
// for production. Because the SecurityPermission attribute bypasses the security check for callers of
// your constructor, it's not recommended for production purposes.
// [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)]
public LinkButton()
{
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
InitializeControl();
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void CreateChildControls()
{
if (LnkButton != null)
{
LnkButton.Text = LinkText;
if (OpenModal)
{
LnkButton.Attributes.Add("onclick", "OpenModalPopup('" + Link.ToString() + "');");
}
else
{
LnkButton.PostBackUrl = Link.ToString();
}
}
}
}
}
嘗試初始化這些值與默認開始 - 這是否工作?然後,您可以確定它的配置,或者不太有效的鏈接按鈕。 – Ian