1

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 Message: 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

1
  • 2
    Need your complete block of code, the above is incomplete. Cant see where </asp:ConfirmLinkButton> opens for example. Commented Mar 12, 2010 at 20:01

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

can you tell us, which name-space is this class from:` WebControlUtils`
Asad Butt exactly. namespace WebControlUtils
hmm i need (), maybe do you have any other idea?
I really am confused about this WebControlUtils class. would be great and very helpful to check, if you can pass me a link for it's documentation on line
0

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.

1 Comment

It's trying to cast an item to type ConfirmButton.Controls.ConfirmLinkButton, so you have a root namespace with the name ConfirmButton and a control with the identifier ConfirmButton. You shouldn't use a namespace name as the identifier for an object or you will run into problems like this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.