Compilation Error CS1002: ; expected

I typed up an an aspx page, everthing looked good--it worked, and then suddenly it doens't work anymore.  I get an 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: CS1002: ; expected

Line 322:            #line default
Line 323:            #line hidden
Line 324:            parameterContainer.Controls[1].RenderControl(__output);
Line 325:        }
Line 326:        


The Line error isn't in my code. I've looked on the internet and only found something about modifying the code too much so I RETYPED the whole thing again by hand.  Same problem.

Can anyone help?

I don't know but could it be that I user make a SqlParameter for the querystring "categoryID" for 4 command objects because I need it 4 times?

            cmd3.CommandType=CommandType.StoredProcedure;
            cmd3.Parameters.Add("@urlCatID",SqlDbType.Int);
            cmd3.Parameters["@urlCatID"].Value=Request.Querystring["categoryID"];

LVL 1
champ_010Asked:
Who is Participating?
 
tovvenkiCommented:
Hi,
I think the problem lies here. in your script section you are declaring and initializing CatName variable inside the IsPostBack check like this
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
     if(!IsPostBack){
     
          //string CatID=Request.QueryString["catID"];
          string CatName=Request.QueryString["Category"];

and when you try to access it like this
=<%=CatName;%>"

you will get the following error
Compiler Error Message: CS1026: ) expected

so modify the code block like this

script runat="server">
string CatName;
void Page_Load(object sender, EventArgs e)
{

     if(!IsPostBack){
            
          //string CatID=Request.QueryString["catID"];
           CatName=Request.QueryString["Category"];

and now access the variable like this
<%=CatName %>

It should work

regards,
venki
0
 
tovvenkiCommented:
Hi,
the following error "Compilation Error CS1002: ; expected" will be reported if you have missed ; in any of the lines. Check whether every line ends with a ;

regards,
venki
0
 
tovvenkiCommented:
and also since the parameter is of type int you should also convert it to int like
cmd3.Parameters["@urlCatID"].Value=Convert.ToInt32(Request.Querystring["categoryID"].ToString());

regards,
venki
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
champ_010Author Commented:

The error line referred to isn't even in my code--it's some hidden thing.  I don't have 324 lines in my code.

I've tried the converting to int but doesn't help--but the error message does seem to refer to a parameter problem....
0
 
ihenryCommented:
>> The error line referred to isn't even in my code--it's some hidden thing
sounds like .net indexing is having problem.

try this,
1. close all of open vs.net ide
2. restart iis
3. remove all files under %Windir%\Microsoft. net\Framework\v1.1.4322\Temporary ASP.NET Files\ or %Windir%\Microsoft. net\Framework\v1.0.3705\Temporary ASP.NET Files\ if you have ver1.0 installed.
4. remove all files under C:\Documents and Settings\<yourUserName>\VSWebCache\<yourMachineName>

re-open the project / solution and then recompile.
0
 
champ_010Author Commented:
o.k. will try now...
0
 
champ_010Author Commented:
hi, still the same... should i paste some of my code or is it the .net indexing thing?
0
 
champ_010Author Commented:
Here is the Detailed Compiler Output:

C:\WINNT\system32> "c:\winnt\microsoft.net\framework\v1.1.4322\csc.exe" /t:library /utf8output /R:"c:\winnt\assembly\gac\system.web\1.0.5000.0__b03f5f7f11d50a3a\system.web.dll" /R:"c:\winnt\microsoft.net\framework\v1.1.4322\temporary asp.net files\root\5332f0cc\21856cf4\py2s4vna.dll" /R:"c:\winnt\microsoft.net\framework\v1.1.4322\temporary asp.net files\root\5332f0cc\21856cf4\psruf4hj.dll" /R:"c:\winnt\microsoft.net\framework\v1.1.4322\mscorlib.dll" /R:"c:\winnt\microsoft.net\framework\v1.1.4322\temporary asp.net files\root\5332f0cc\21856cf4\pwwio1xw.dll" /R:"c:\winnt\assembly\gac\system.enterpriseservices\1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseservices.dll" /R:"c:\winnt\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll" /R:"c:\winnt\assembly\gac\system.web.mobile\1.0.5000.0__b03f5f7f11d50a3a\system.web.mobile.dll" /R:"c:\winnt\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll" /R:"c:\winnt\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll" /R:"c:\winnt\assembly\gac\system.web.services\1.0.5000.0__b03f5f7f11d50a3a\system.web.services.dll" /R:"c:\winnt\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll" /out:"C:\WINNT\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\5332f0cc\21856cf4\erd6-nv3.dll" /D:DEBUG /debug+ /optimize- /win32res:"C:\WINNT\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\5332f0cc\21856cf4\erd6-nv3.res" /warnaserror /w:1  "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\5332f0cc\21856cf4\erd6-nv3.0.cs"


Microsoft (R) Visual C# .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.

c:\WINNT\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\5332f0cc\21856cf4\erd6-nv3.0.cs(325,31): error CS1002: ; expected
c:\WINNT\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\5332f0cc\21856cf4\erd6-nv3.0.cs(325,31): error CS1001: Identifier expected
C:\electronics\categoriesMain.aspx(122,66): error CS0117: 'System.Web.UI.WebControls.RepeaterItem' does not contain a definition for 'Eval'
C:\electronics\categoriesMain.aspx(134,66): error CS0246: The type or namespace name 'DataItem' could not be found (are you missing a using directive or an assembly reference?)
c:\WINNT\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\5332f0cc\21856cf4\erd6-nv3.0.cs(766,21): error CS1002: ; expected
c:\WINNT\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\5332f0cc\21856cf4\erd6-nv3.0.cs(766,21): error CS1001: Identifier expected

 


0
 
ihenryCommented:

ok, I have the assumption because you were mentioning that the error message was showing something that is not from your code. try one last try before pasting your code here.

Close the ide, remove all files which have .dll, .pdb and .projdata extension. they're usually under folder bin\debug and bin\release or object\debug and object\release for each project.

re-open the solution and then re-compile.
0
 
ihenryCommented:
0
 
champ_010Author Commented:
I'm not using VS.net.  I'm hand coding this.... with everything on the same page script above html below...
0
 
champ_010Author Commented:
Sorry, not so good with computers--what is Indexing Service--how do i know if i use it?

Thanks
0
 
ihenryCommented:

The article only apply if you have indexing service installed on your machine. It's under IIS.
0
 
tovvenkiCommented:
Hi,
"I'm not using VS.net.  I'm hand coding this."
C# is case-sensitive since you are not using vs.net check whether you are using proper cases for keywords.
also can you paste the code here.

regards,
venki
0
 
ihenryCommented:
>> "I'm not using VS.net.  I'm hand coding this
well, I made wrong assumption this far...
0
 
champ_010Author Commented:
Yes I will paste code here.  I'm new to this and I saw the page working perfectly displaying all output then suddenly didn't.
I might have accidentally done something.  Also, because I'm new to this my coding may not be the best.
By the way, the other pages are still displaying nicely with all database outputs happening as they should.

Thanks for taking a look.
0
 
champ_010Author Commented:

<%@ Page Language="C#"%>
<%@ Import Namespace="System.IO"%>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<%@ Import Namespace="System.Web"%>
<%@ Import Namespace="System.Web.UI"%>
<%@ Import Namespace="System.Web.UI.WebControls"%>

<%@ Register TagPrefix="HypeTech" TagName="TopNav" Src="uc_topNav.ascx"%>
<%@ Register TagPrefix="HypeTech" TagName="SearchNav" Src="uc_search.ascx"%>
<%@ Register TagPrefix="HypeTech" TagName="Footer" Src="uc_footer.ascx"%>

<script runat="server">
void Page_Load(object sender, EventArgs e)
{
      if(!IsPostBack){
      
            //string CatID=Request.QueryString["catID"];
            string CatName=Request.QueryString["Category"];
            
            SqlConnection myConn=new SqlConnection();
            myConn.ConnectionString=ConfigurationSettings.AppSettings["HypeTechConn"];
            myConn.Open();
            
            //Get SubCategories
            SqlCommand cmd1=new SqlCommand("GetSubCategories",myConn);
            cmd1.CommandType=CommandType.StoredProcedure;
            cmd1.Parameters.Add("@urlCatID",SqlDbType.Int,4);
            cmd1.Parameters["@urlCatID"].Value=Convert.ToInt32(Request.QueryString["categoryID"].ToString());
            
            SqlDataReader dr1=cmd1.ExecuteReader();
            SubCatList.DataSource=dr1;
            SubCatList.DataBind();
            dr1.Close();
            
            //GetFeatures_upper
            SqlCommand cmd2=new SqlCommand("GetFeaturesTop",myConn);
            cmd2.CommandType=CommandType.StoredProcedure;
            cmd2.Parameters.Add("@urlCatID",SqlDbType.Int,4);
            cmd2.Parameters["@urlCatID"].Value=Convert.ToInt32(Request.QueryString["categoryID"].ToString());
            
            SqlDataReader dr2=cmd2.ExecuteReader();
            Features_upper.DataSource=dr2;
            Features_upper.DataBind();
            dr2.Close();
            
            //GetFeatures_lower
            SqlCommand cmd3=new SqlCommand("GetFeaturesBottom",myConn);
            cmd3.CommandType=CommandType.StoredProcedure;
            cmd3.Parameters.Add("@urlCatID",SqlDbType.Int,4);
            cmd3.Parameters["@urlCatID"].Value=Convert.ToInt32(Request.QueryString["categoryID"].ToString());
            
            SqlDataReader dr3=cmd3.ExecuteReader();
            Features_lower.DataSource=dr3;
            Features_lower.DataBind();
            
            
            //Get Guides
            SqlCommand cmd4=new SqlCommand("GetGuideHeader",myConn);
            cmd4.CommandType=CommandType.StoredProcedure;
            cmd4.Parameters.Add("@urlCatID",SqlDbType.Int,4);
            cmd4.Parameters["@urlCatID"].Value=Convert.ToInt32(Request.QueryString["categoryID"].ToString());
            
            SqlDataReader dr4=cmd4.ExecuteReader();
            GuidesList.DataSource=dr4;
            GuidesList.DataBind();
            dr4.Close();
            
            myConn.Close();
      }
}
</script>


I'm omitting the HTML stuff and just including the web controls to make it short--let me know if all of it is needed...

<asp:Repeater ID="SubCatList" runat="server">
  <ItemTemplate>
       <tr>
        <td nowrap bgcolor="#E9EAEB">
              <a href="products.aspx?subCatID=<%#DataBinder.Eval(Container.DataItem,"subCatID")%>&category=<%CatHeader%>" class="h5_roll">
                  <%#DataBinder.Eval(Container.DataItem,"subCatName")%></a></td>
      </tr>
  </ItemTemplate>
</asp:Repeater>

<asp:Repeater ID="Features_upper" runat="server">
  <ItemTemplate>
        <tr bgcolor="#B8C1C7">
                       <td colspan="2" class="h4_FFFFFF" style="line-height:130%">
              <img src="<%#DataBinder.Eval(Container.DataItem,"featureImage")%>" width="130" height="100" hspace="10" vspace="5" align="left" alt="">
              <span class="h4_b_FFFFFF"><%#DataBinder.Eval(Container.DataItem,"featureTitle")%></span><br>
              <%#DataBinder.Eval(Container.DataItem,"featureText")%><br>
            <span class="h4_4A4152">$<%#DataBinder.Eval(Container.DataItem,"productPrice")%></span>&nbsp;&nbsp;&nbsp;
            <a href="details.aspx?productID=<%#Container.Eval(Container.DataItem,"productID")%>" class="details">Details</a>
             </td>
        </tr>
  </ItemTemplate>
</asp:Repeater>

<asp:Repeater ID="Features_lower" runat="server">
   <ItemTemplate>                        
         <td height="91" bgcolor="#FFFFFF" class="h5_4A4152" style="line-height:130%; border:1px solid #EEEEEE;" width="50%" valign="top">
               <img src="<%#DataBinder.Eval(Container.DataItem,"featureImage")%>" width="60" height="60" align="left" hspace="5" alt="">
            <span class="h4_b_4A4152"><%#DataBinder.Eval(Container.DataItem,"featureTitle")%></span>&nbsp;
            <%#DataBinder.Eval(Container.DataItem,"FeatureText")%><br>
            <span class="h4_b_4A4152">$<%#DataItem.Eval(Container.DataItem,"productPrice")%></span>
            <a href="details.aspx?productID=<%#DataBinder.Eval(Container.DataItem,"productID")%>" class="details">Details</a>
         </td>
  </ItemTemplate>
</asp:Repeater>

<asp:Repeater ID="GuidesList" runat="server">
   <ItemTemplate>
      <img src="images/bullet.gif" width="8" height="8" hspace="5" vspace="3">
      <a href="guides.aspx?guideID=<%#DataBinder.Eval(Container.DataItem,"guideID")%>" class="h5_69BAC0">
      <%#DataBinder.Eval(Container.DataItem,"guideHeaderName")%></a><br>
</ItemTemplate>                        
</asp:Repeater>
0
 
ihenryCommented:
you forgot this

<%@ Import Namespace="System.Configuration"%>
0
 
champ_010Author Commented:
Thanks, but it wasn't the cause of my problem.
0
 
ihenryCommented:

sure it is, you won't be able to make a call to ConfigurationSettings.AppSettings property without importing this namespace.
but if you're still getting error means you have another problem.
0
 
champ_010Author Commented:

Hey, I think it's something wrong with this line--the second thing I'm trying to pass <%CatHeader%> was one of the last things I was working on...
I figure it's this because I just tried to add another querystring and the error was similar but refered to that line...

  <td nowrap bgcolor="#E9EAEB">
        <a href="products.aspx?subCatID=<%#DataBinder.Eval(Container.DataItem,"subCatID")%>&category=<%CatHeader%>" class="h5_roll">
      <%#DataBinder.Eval(Container.DataItem,"subCatName")%></a></td>
0
 
champ_010Author Commented:

I didn't have it in my other pages but they still displayed....but I'm not the expert and thanks for pointing it out...
0
 
ihenryCommented:
..you are right! try this

category=<%=CatHeader%>
0
 
champ_010Author Commented:
Sorry I was fiddling around with it--the querystring actually does say <%CatName%>...the original problem still exists.

<a href="products.aspx?subCatID=<%#DataBinder.Eval(Container.DataItem,"subCatID")%>&category=<%CatName%>" class="h5_roll">
0
 
champ_010Author Commented:
o.k. will try the extra =
0
 
ihenryCommented:

but it strange..
category=<%CatHeader%> shouldn't give you any problem, tho..
0
 
tovvenkiCommented:
Hi,
I think the line
category=<%=CatHeader%>

should be like this
category=<%=CatHeader;%>

Regards,
venki
0
 
champ_010Author Commented:

Hey are we close or what? The error message change--no more reference to the semicolon ;
Now it's:

Compiler Error Message: CS1026: ) expected

Line 98:              <tr>
Line 99:               <td nowrap bgcolor="#E9EAEB">
Line 100:                    <a href="products.aspx?subCatID=<%#DataBinder.Eval(Container.DataItem,"subCatID")%>&category=<%=CatName;%>" class="h5_roll">
Line 101:                  <%#DataBinder.Eval(Container.DataItem,"subCatName")%></a></td>
Line 102:            </tr>


0
 
ihenryCommented:
>> category=<%=CatName;%>"
I have a bunch of this kind of code embedding in my aspx, I use c# and never put semicolon behind.
Now the code is running the production without any problem. So I guess that's not the problem.

0
 
tovvenkiCommented:
Hi,
see whether the following discussion helps you
http://dotnet247.com/247reference/msgs/4/23527.aspx

regards,
venki
0
 
tovvenkiCommented:
Hi,
try like this
<a href="products.aspx?subCatID='<%#DataBinder.Eval(Container.DataItem,"subCatID")%>'&category=<%=CatName;%>" class="h5_roll">

instead of
<a href="products.aspx?subCatID=<%#DataBinder.Eval(Container.DataItem,"subCatID")%>&category=<%=CatName;%>" class="h5_roll">

Regards,
venki
0
 
ihenryCommented:
omg..., the message is very misleading...

<asp:Repeater ID="Features_upper" runat="server">
  <ItemTemplate>
       <tr bgcolor="#B8C1C7">
                       <td colspan="2" class="h4_FFFFFF" style="line-height:130%">
            <img src="<%#DataBinder.Eval(Container.DataItem,"featureImage")%>" width="130" height="100" hspace="10" vspace="5" align="left" alt="">
            <span class="h4_b_FFFFFF"><%#DataBinder.Eval(Container.DataItem,"featureTitle")%></span><br>
            <%#DataBinder.Eval(Container.DataItem,"featureText")%><br>
          <span class="h4_4A4152">$<%#DataBinder.Eval(Container.DataItem,"productPrice")%></span>&nbsp;&nbsp;&nbsp;
          <a href="details.aspx?productID=<%#Container.Eval(Container.DataItem,"productID")%>" class="details">Details</a>
            </td>
       </tr>
  </ItemTemplate>
</asp:Repeater>

champ_010,
you have <tr> without enclosed with <table>
use this structure
<table>
<tr>
    <td></td>
</tr>
<tr>
    <td></td>
</tr>
</table>
0
 
champ_010Author Commented:
Hi, no that's not it either but here's  a bit of good news--when I remove any reference to <%=CatName;%> or <%=CatName%> or whatever
and just type in the the querystring, the page shows up fine!

Can someone please look at how I am retrieving the querystring incorrectly at the top:

string CatName=Request.QueryString["Category"];

Thanks

BTW--yes I found all the other typos in the code after removing the  <%=CatName;%> so the page shows but the displaying of
the querystring still gives the same error so I'm pretty sure it's this.
0
 
ihenryCommented:
i guess its value is null,
do you pass the query parameter in the url?
0
 
ihenryCommented:
try this,

string CatName=Request.QueryString["Category"];
if ( CatName == null ) return;

See if it is still showing error message.
0
 
champ_010Author Commented:

ihenry,

I do have <table></table> tags etc.  remember I'm only providing the User Control portion--not the whole HTML page--just to keep things
shorter.  The page DOES show up nicely when no reference to the <%=CatName;%>--which I believe is THE problem!!

Thanks
0
 
champ_010Author Commented:

No, that's not the problem either--I even typed it in the address bar to make sure.

I've used this on another part of the page to try to display but it gives the same error that  ) is expected:

<span class="h4_b_666666"><%=CatName;%></span>
0
 
ihenryCommented:
where did you declare the CatHeader var?
0
 
champ_010Author Commented:
It's there, I pasted the wrong copy it is Declared CatName and used as CatName...
0
 
tovvenkiCommented:
Hi,
for testing purpose I tried with the following aspx file
<%@ Page Language="C#"%>
<script runat="server">
string CatName;
void Page_Load(object sender, EventArgs e)
{

     if(!IsPostBack){
            
          //string CatID=Request.QueryString["catID"];
           CatName=Request.QueryString["Category"];
     }
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
      <HEAD>
            <title>WebForm1</title>
            <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
            <meta name="CODE_LANGUAGE" Content="C#">
            <meta name="vs_defaultClientScript" content="JavaScript">
            <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
      </HEAD>
      <body MS_POSITIONING="GridLayout">
            <form id="Form1" method="post" runat="server">
            <%=CatName %>
            </form>
      </body>
</HTML>

and when I access the webform like this
http://localhost/WebApplication29/WebForm1.aspx?Category=bbb

I got the display bbb

I hope that this helps you

PS- I think when you declare a variable within a {} block it will be accessible from only that block i.e its scope will be limited
to only that block. I think this is what is causing you the problem.

Regards,
venki
0
 
champ_010Author Commented:

venki,

THANK YOU! That was the problem.

I think I know what you mean about initializing it inside the Page_Load...if I vaguely remember my C# classes.

If you have a brief explanation that would be great too, otherwise thanks to both you and ihenry for your patience with this.
0
 
champ_010Author Commented:
Hi, I posted before reading your latest posting.  The explanation you have provided is exactely what I needed.  
Thanks again!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.