'System.Web.UI.Control.Controls' is a 'property' but is used like a 'type'
What i am doing wrong? I extend LinkButton and i get this error
Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Me开发者_运维百科ssage: CS0118: 'System.Web.UI.Control.Controls' is a 'property' but is used like a 'type'
Source Error:
Line 1084: Line 1085:
public void @__DataBinding__control30(object sender, System.EventArgs e) { Line 1086: ConfirmButton.Controls.ConfirmLinkButton dataBindingExpressionBuilderTarget; Line 1087: System.Web.UI.IDataItemContainer Container; Line 1088: dataBindingExpressionBuilderTarget = ((ConfirmButton.Controls.ConfirmLinkButton)(sender));
This is C# code:
[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 CODE:
<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);
}
}
Regards
Try
Page.IsAsyncPostBack
Page class has a property: Page.IsPostBack. you should not use ()
to access a property of any class. This is the reason you are getting this error.
It looks like you have a control named 'ConfirmButton' in the local namespace. You should rename this control, since that identifier is already used as a namespace name.
精彩评论