Michael
Michael

Reputation: 13636

Compiler Error Message in row LinkButton declaration

I have the following ASP code:

<asp:LinkButton ID="LinkButton1" runat="server" Text="edit item" onclick='AddItem.aspx?catid=<%# Eval("CollectionID")%>' />

In this row i get Error compilation:

Compiler Error Message: CS1040: Preprocessor directives must appear as the first non-whitespace character on a line

Why do I get this error and how can i fix it? Thank you in advance!

Upvotes: 0

Views: 965

Answers (2)

Ashfaq Shaikh
Ashfaq Shaikh

Reputation: 1668

You can do it in this way.

<asp:LinkButton ID="LinkButton1" runat="server" Text="edit item" 
PostBackUrl='AddItem.aspx?catid=<%# Eval("CollectionID")%>' />

Upvotes: 2

EverPresent
EverPresent

Reputation: 1970

Are you certain that this is the line causing the problem? Generally when you see this error it is because there is a problem with your <@ > page directives at the top of the code. Make sure your <@Page> directive is the very first thing in the file and that it's formatted correctly and that you don't have any other <@ symbols in your code aside from your page directives.

Upvotes: 0

Related Questions