类,结构或接口成员声明中的标记')'无效

时间:2011-07-06 14:20:40

标签: .net

这是我的代码,我在类,结构或接口成员声明中得到错误“无效标记”),“任何帮助,

- aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="Main_test" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

        <asp:CheckBox ID="CheckBox1" runat="server"  AutoPostBack="true" />

        <%  if (CheckBox1.Checked) {  %>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" >
            <ContentTemplate>          

        <%  } %>

        Something

         <%  if (CheckBox1.Checked ) {   %> // Error is Here at )  

            </ContentTemplate>
        </asp:UpdatePanel>
        <%   } %>
    </form>
</body>
</html>

- aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Main_test : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

1 个答案:

答案 0 :(得分:0)

我认为你不能只为你的updatepanel添加一个if开头或者结束标记。 您可以尝试使用以下命令更改代码:

   <%  if (CheckBox1.Checked) {  %>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" >
        <ContentTemplate>          
    Something
        </ContentTemplate>
    </asp:UpdatePanel>
    <%   } else { %>
    Something
    %>