我做错了什么?我扩展了LinkButton,我得到了这个错误
编译错误说明:An 编译期间发生错误 为此提供服务所需的资源 请求。请查看以下内容 具体的错误细节和修改你的 适当的源代码。
编译器错误消息:CS0118: 'System.Web.UI.Control.Controls'是一个 'property'但用作'type'
来源错误:
第1084行:第1085行:
公共无效 @__ DataBinding__control30(对象 sender,System.EventArgs e){Line 1086:
ConfirmButton.Controls.ConfirmLinkButton dataBindingExpressionBuilderTarget; 1087行:
System.Web.UI.IDataItemContainer 容器; 1088行:
dataBindingExpressionBuilderTarget = ((ConfirmButton.Controls.ConfirmLinkButton)(发送者));
这是C#代码:
[Localizable(true)]
public string Message
{
get { return ViewState["Message"] as string; }
set { ViewState["Message"] = value; }
}
#region Overriden
protected override void OnPreRender(EventArgs e)
{
if (!String.IsNullOrEmpty(Message))
{
WebControlUtils.SetConfirmationMessage(Page, typeof (Page), this, Message, Page.IsAsyncPostBack(),
CausesValidation);
}
base.OnPreRender(e);
}
#endregion
ASPX代码:
<asp:TemplateField>
<ItemTemplate>
<asp:ConfirmLinkButton ID="lnkBtnDelete" runat="server" Text="Odstrani" Message="Delete?"
CommandName="DeleteAgencie" Width="50"
CommandArgument='<%# Eval("idAgencies") %>'
OnCommand="lnkBtnDelete_Command" CausesValidation="False"></asp:ConfirmLinkButton>
</ItemTemplate>
</asp:TemplateField>
C#
public static bool IsAsyncPostBack(this Page page)
{
var result = false;
var scriptManager = ScriptManager.GetCurrent(page);
if (scriptManager != null)
{
result = scriptManager.IsInAsyncPostBack;
}
return result;
}
public static void SetConfirmationMessage(Page page, Type type, Control control, string message,
bool isAsyncPostBack, bool causesValidation)
{
string script = "SetConfirmation('" + control.ClientID + "','" + message + "'," +
causesValidation.ToString().ToLower() + ");";
if (isAsyncPostBack)
{
ScriptManager.RegisterStartupScript(page, typeof (Page), control.ClientID, script, true);
}
else
{
page.ClientScript.RegisterStartupScript(type, control.ClientID, script, true);
}
}
此致
答案 0 :(得分:1)
答案 1 :(得分:0)
看起来你在本地命名空间中有一个名为'ConfirmButton'的控件。您应该重命名此控件,因为该标识符已用作命名空间名称。