开发者

using If statment included in axpx page generates compile error

i have a default.aspx

and a sidebar.aspx

i included the si开发者_开发问答debar in my default by :

<!--#include file="../sidebar.aspx"-->  

it included successfully without any error i used this code in my sidbar file :

<% if (True) { %>
    <div class="left-box">
        ....
    </div>
<% } %>

it works fine when i refresh the page @ development server but vs 2010 shows compile error :

Error 25 End of statement expected. C:\Users\user\Documents\Visual Studio 2010\WebSites\WebSite2\sidebar.aspx 6

Error 24 'If' must end with a matching 'End If'. C:\Users\user\Documents\Visual Studio 2010\WebSites\WebSite2\sidebar.aspx 6

Error 26 Syntax error. C:\Users\user\Documents\Visual Studio 2010\WebSites\WebSite2\sidebar.aspx 22

UPDATEEEEEEEEEEEEEEE ! -> at top of my default.aspx is -> <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> and then i included my sidebar.aspx .... i dont know why sidebar run as VB ... i didnt use any page language at top of this file ... and it should use the default.aspx language


Check the 'language' attribute in your <%@ Page %> directive. Make sure it is set to "c#" (the error message makes it sound like the page is using vb)


change True to true. It's trying to compile as VB.NET


Other than changing the "True", to "true", it works fine for me...are you sure the page is expecting C# code, and not VB code?


An alternative:

if ( 1 == 1) {
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜