开发者

Invalid token ')' in class, struct, or interface member declaration

开发者 https://www.devze.com 2023-03-17 22:32 出处:网络
Here is my code, I got error \"Invalid token \')\' in class, struct, or interface member declaration\", any help ,

Here is my code, I got error "Invalid token ')' in class, struct, or interface member declaration", any help ,

-- 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:ScriptM开发者_StackOverflow中文版anager 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)
    {

    }
}


I think you can't put an if around just the opening or the closing tag for your updatepanel. You can try changing your code with:

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

精彩评论

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