Error messages due to conversion from older ASP.Net

  • Thread starter CdnRebel via DotNetMonster.com
  • Start date
C

CdnRebel via DotNetMonster.com

Hi,

I am new to ASP.Net, C# and Visual Studio 5. I have until tonight to
complete changes to a website, otherwise it gets passed on to a web
development company, if not up and running. I've made all the changes, but
with having an older version of ASP.Net and using Visual Studio 5, I am
having trouble getting a clean compile and I believe that's all that's
holding me back from loading the website changes. The above is just one of
the slew of messages I am getting on this one bit of code and I don't
understand the messages or how to fix them. It doesn't help that it's after
midnight here. The following is the code, lines 21 to 61:

namespace Furniture

{

/// <summary>

/// Summary description for AddNewProduct.

/// </summary>

// public partial class Migrated_AddNewProduct : AddNewProduct

{

protected System.Web.UI.WebControls.LinkButton lnkAddNewProduct;

protected System.Web.UI.WebControls.RequiredFieldValidator
Requiredfieldvalidator3;


protected void Page_Load(object sender, System.EventArgs e)

{

if(Session["SessionUserID"] != null)

{

lnkTopRight.Text="ADMINISTRATION";

lnkTopRight.NavigateUrl="ProductManagement.aspx";

}

else

{

lnkTopRight.Text="LOG IN";

lnkTopRight.NavigateUrl="login.aspx";

}

txtOrderNumber.Attributes.Add("OnChange", "ClientOnChange();");

int intCatID = 0;

int intSubID=0;

if(!IsPostBack)

{

if(Request["CatID"] !=null)

{

intCatID=int.Parse(Request["CatID"] .ToString());

}

if(Request["SubID"] !=null)

{

intSubID=int.Parse(Request["SubID"] .ToString());

}

LoadCategoryList(intCatID,intSubID);

}

}

The following are the errors that I got:

Error 1 A namespace does not directly contain members such as fields or
methods ...line 27 column 2

Error 2 Expected class, delegate, enum, interface, or struct ...line 28
column 13

Error 3 Expected class, delegate, enum, interface, or struct ...line 29
column 13

Error 4 Expected class, delegate, enum, interface, or struct ...line 31
column 13

Error 5 Identifier expected ...line 33 column 15

Error 6 Identifier expected ...line 51 column 16

Error 7 Identifier expected ...line 53 column 33

Error 8 A namespace does not directly contain members such as fields or
methods ...line 55 column 5

Error 9 Identifier expected ...line 55 column 16

Error 10 Identifier expected ...line 57 column 33

Error 11 Type or namespace definition, or end-of-file expected ...line 58
column 5

Error 12 The namespace 'Furniture' already contains a definition for '?' line
51 column 15

Error 13 The namespace 'Furniture' already contains a definition for '?' ...
line 53 column 32

Error 14 The namespace '<global namespace>' already contains a definition for
'?' ...line 57 column 32

Can someone please help? I was supposed to get help tonight, but he bailed
without any warning and I am working on this by myself.
 
B

Brandon Gano

This is a case of staring at your code too long, I think.

If you remove the // comment from the "public partial class
Migrated_AddNewProduct : AddNewProduct" line, it should get rid of most of
those errors.


CdnRebel via DotNetMonster.com said:
Hi,

I am new to ASP.Net, C# and Visual Studio 5. I have until tonight to
complete changes to a website, otherwise it gets passed on to a web
development company, if not up and running. I've made all the changes,
but
with having an older version of ASP.Net and using Visual Studio 5, I am
having trouble getting a clean compile and I believe that's all that's
holding me back from loading the website changes. The above is just one
of
the slew of messages I am getting on this one bit of code and I don't
understand the messages or how to fix them. It doesn't help that it's
after
midnight here. The following is the code, lines 21 to 61:

namespace Furniture

{

/// <summary>

/// Summary description for AddNewProduct.

/// </summary>

// public partial class Migrated_AddNewProduct : AddNewProduct

{

protected System.Web.UI.WebControls.LinkButton lnkAddNewProduct;

protected System.Web.UI.WebControls.RequiredFieldValidator
Requiredfieldvalidator3;


protected void Page_Load(object sender, System.EventArgs e)

{

if(Session["SessionUserID"] != null)

{

lnkTopRight.Text="ADMINISTRATION";

lnkTopRight.NavigateUrl="ProductManagement.aspx";

}

else

{

lnkTopRight.Text="LOG IN";

lnkTopRight.NavigateUrl="login.aspx";

}

txtOrderNumber.Attributes.Add("OnChange", "ClientOnChange();");

int intCatID = 0;

int intSubID=0;

if(!IsPostBack)

{

if(Request["CatID"] !=null)

{

intCatID=int.Parse(Request["CatID"] .ToString());

}

if(Request["SubID"] !=null)

{

intSubID=int.Parse(Request["SubID"] .ToString());

}

LoadCategoryList(intCatID,intSubID);

}

}

The following are the errors that I got:

Error 1 A namespace does not directly contain members such as fields or
methods ...line 27 column 2

Error 2 Expected class, delegate, enum, interface, or struct ...line 28
column 13

Error 3 Expected class, delegate, enum, interface, or struct ...line 29
column 13

Error 4 Expected class, delegate, enum, interface, or struct ...line 31
column 13

Error 5 Identifier expected ...line 33 column 15

Error 6 Identifier expected ...line 51 column 16

Error 7 Identifier expected ...line 53 column 33

Error 8 A namespace does not directly contain members such as fields or
methods ...line 55 column 5

Error 9 Identifier expected ...line 55 column 16

Error 10 Identifier expected ...line 57 column 33

Error 11 Type or namespace definition, or end-of-file expected ...line 58
column 5

Error 12 The namespace 'Furniture' already contains a definition for '?'
line
51 column 15

Error 13 The namespace 'Furniture' already contains a definition for '?'
...
line 53 column 32

Error 14 The namespace '<global namespace>' already contains a definition
for
'?' ...line 57 column 32

Can someone please help? I was supposed to get help tonight, but he
bailed
without any warning and I am working on this by myself.
 
C

CdnRebel via DotNetMonster.com

Thanks Brandon,

That got rid of the previous messages. Now I have a new slew of messages
regarding the same C# file:

The name 'lnkTopRight' does not exist in the current context ...line 35
column 5
The name 'lnkTopRight' does not exist in the current context ...line 36, 41,
42 column 5
The name 'txtOrderNumber' does not exist in the current context ...line 45
column 13
The name 'lstCategory' does not exist in the current context ...line 66, 67,
68, 69 column 4
The name 'lstCategory' does not exist in the current context ...line 70
column 7

The following are the lines of code from 25 to 143 and there were similar
messages all the way to line 335.

Would you have a quick answer for these as well?

Thanks again,
Mary



public partial class Migrated_AddNewProduct : AddNewProduct
{
protected System.Web.UI.WebControls.LinkButton lnkAddNewProduct;
protected System.Web.UI.WebControls.RequiredFieldValidator
Requiredfieldvalidator3;

protected void Page_Load(object sender, System.EventArgs e)
{
if(Session["SessionUserID"] != null)
{
lnkTopRight.Text="ADMINISTRATION";
lnkTopRight.NavigateUrl="ProductManagement.aspx";
}
else
{

lnkTopRight.Text="LOG IN";
lnkTopRight.NavigateUrl="login.aspx";
}

txtOrderNumber.Attributes.Add("OnChange", "ClientOnChange();");
int intCatID = 0;
int intSubID=0;

if(!IsPostBack)
{
if(Request["CatID"] !=null)
{
intCatID=int.Parse(Request["CatID"] .ToString());
}
if(Request["SubID"] !=null)
{
intSubID=int.Parse(Request["SubID"] .ToString());
}
LoadCategoryList(intCatID,intSubID);
}
}
void LoadCategoryList(int intCatID, int intSubID)
{
ProductDB catDB=new ProductDB();
DataView dv=catDB.GetCategory();
lstCategory.DataSource=dv;
lstCategory.DataValueField="fldCategoryID";
lstCategory.DataTextField="fldCategoryName";
lstCategory.DataBind();
if(lstCategory.Items.Count >0)
{
for(int i=0; i< lstCategory.Items.Count; i++)
{
if(int.Parse(lstCategory.Items.Value.ToString())== intCatID)
{
lstCategory.Items.Selected=true;
break;
}
}
LoadSubCategoryList(int.Parse(lstCategory.Items[lstCategory.SelectedIndex]
.Value),intSubID);
}
else
{
lstCategory.Items.Add(new ListItem("No data available","0"));
lstCategory.Items[0].Selected=true;
}
}
void LoadProductList(int intSubCategoryID)
{
bool blnDisplayedOnThumbnailPage=true;
ProductDB oDB=new ProductDB();
DataSet ds=oDB.GetProductsBySubCategory(intSubCategoryID,
blnDisplayedOnThumbnailPage);
if(ds.Tables[0].Rows.Count > 0)
{
dplProduct.DataTextField="fldProductName";
dplProduct.DataValueField="fldProductID";
dplProduct.DataSource=ds;
dplProduct.DataBind();
dplProduct.Items.Insert(0,"Choose a similar item");
dplProduct.Items[dplProduct.SelectedIndex].Selected=true;
}
else
{


dplProduct.Items.Add(new ListItem("No data available","0"));
dplProduct.Items[0].Selected=true;
}


}
void LoadSubCategoryList(int intCategoryID, int intSubID)
{
bool hasSelectedItem=false;
ProductDB catDB=new ProductDB();
DataView dv=catDB.GetSubCategory(intCategoryID);
lstSubCategory.DataSource=dv;
lstSubCategory.DataValueField="fldSubCategoryID";
lstSubCategory.DataTextField="fldSubCategoryName";
lstSubCategory.DataBind();
if(lstSubCategory.Items.Count >0)
{
for(int i=0; i< lstSubCategory.Items.Count; i++)
{
if(int.Parse(lstSubCategory.Items.Value.ToString())== intSubID)
{
lstSubCategory.Items.Selected=true;
hasSelectedItem=true;
break;
}
}
if(!hasSelectedItem)
{
lstSubCategory.Items[0].Selected=true;
}
LoadProductList(int.Parse(lstSubCategory.Items[lstSubCategory.
SelectedIndex].Value));
}
else
{
lstSubCategory.Items.Add(new ListItem("No data available","0"));
lstSubCategory.Items[0].Selected=true;
}
}

Brandon said:
This is a case of staring at your code too long, I think.

If you remove the // comment from the "public partial class
Migrated_AddNewProduct : AddNewProduct" line, it should get rid of most of
those errors.
[quoted text clipped - 131 lines]
bailed
without any warning and I am working on this by myself.
 
E

Enkidu

CdnRebel said:
Hi,

I am new to ASP.Net, C# and Visual Studio 5. I have until tonight to
complete changes to a website, otherwise it gets passed on to a web
development company, if not up and running. I've made all the changes, but
with having an older version of ASP.Net and using Visual Studio 5, I am
having trouble getting a clean compile and I believe that's all that's
holding me back from loading the website changes. The above is just one of
the slew of messages I am getting on this one bit of code and I don't
understand the messages or how to fix them. It doesn't help that it's after
midnight here. The following is the code, lines 21 to 61:

namespace Furniture

{

/// <summary>

/// Summary description for AddNewProduct.

/// </summary>

// public partial class Migrated_AddNewProduct : AddNewProduct

{

protected System.Web.UI.WebControls.LinkButton lnkAddNewProduct;

protected System.Web.UI.WebControls.RequiredFieldValidator
Requiredfieldvalidator3;


protected void Page_Load(object sender, System.EventArgs e)

{

if(Session["SessionUserID"] != null)

{

lnkTopRight.Text="ADMINISTRATION";

lnkTopRight.NavigateUrl="ProductManagement.aspx";

}

else

{

lnkTopRight.Text="LOG IN";

lnkTopRight.NavigateUrl="login.aspx";

}

txtOrderNumber.Attributes.Add("OnChange", "ClientOnChange();");

int intCatID = 0;

int intSubID=0;

if(!IsPostBack)

{

if(Request["CatID"] !=null)

{

intCatID=int.Parse(Request["CatID"] .ToString());

}

if(Request["SubID"] !=null)

{

intSubID=int.Parse(Request["SubID"] .ToString());

}

LoadCategoryList(intCatID,intSubID);

}

}

The following are the errors that I got:

Error 1 A namespace does not directly contain members such as fields or
methods ...line 27 column 2

Error 2 Expected class, delegate, enum, interface, or struct ...line 28
column 13

Error 3 Expected class, delegate, enum, interface, or struct ...line 29
column 13

Error 4 Expected class, delegate, enum, interface, or struct ...line 31
column 13

Error 5 Identifier expected ...line 33 column 15

Error 6 Identifier expected ...line 51 column 16

Error 7 Identifier expected ...line 53 column 33

Error 8 A namespace does not directly contain members such as fields or
methods ...line 55 column 5

Error 9 Identifier expected ...line 55 column 16

Error 10 Identifier expected ...line 57 column 33

Error 11 Type or namespace definition, or end-of-file expected ...line 58
column 5

Error 12 The namespace 'Furniture' already contains a definition for '?' line
51 column 15

Error 13 The namespace 'Furniture' already contains a definition for '?' ...
line 53 column 32

Error 14 The namespace '<global namespace>' already contains a definition for
'?' ...line 57 column 32

Can someone please help? I was supposed to get help tonight, but he bailed
without any warning and I am working on this by myself.
The line defining the class Migrated_AddNewProduct is commented. Why is
that?

Cheers,

Cliff
 
C

CdnRebel via DotNetMonster.com

Hi Cliff,

Thanks, the conversion to ASP.Net did that. I had thought that I had looked
for that.

Mary
[quoted text clipped - 124 lines]
Can someone please help? I was supposed to get help tonight, but he bailed
without any warning and I am working on this by myself.

The line defining the class Migrated_AddNewProduct is commented. Why is
that?

Cheers,

Cliff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top