Search
Sponsor
Winners

Win Prizes

Social Presence
Twitter Twitter LinkedIn YouTube Google

Like us on Facebook
Advertisements
Top Forums Author
Thu, 02-Oct-2014 Authors
All Time Authors
Jayakumars
4170
Karthikanbarasan
3455
Chvrsri
3140

Latest members | More ...


(Statistics delayed by 5 minutes)
 Forum Post

A namespace does not directly contain members such as fields or methods [Resolved]

Sudheep.grandhe
Posted by Sudheep.grandhe under C# on 10/11/2011 12:54:42 AM | Points: 10 | Views : 11297 | Status : [Member] | Replies : 14


Hi,

I've been getting the error:

A namespace does not directly contain members such as fields or methods

which points to the first line of my Beclass.cs ,
e.g.-public string_uname{}
{
get

Best,
Sudheep.


Posted by: Blessyjees on: 10/11/2011 [Member] Bronze | Points: 25

Hi,

Are you used the namespace as field or method name. Could you privide the full code of the page.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 10/11/2011 [Member] Starter | Points: 25

Hi,

Here i am attaching the full code of my beclass.cs.please rectify the error.please do the needful.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration ;
using System.Data ;
using System.Web ;
using System.Web .UI ;
using System.Web .UI.HtmlControls ;
using System.Web .UI.WebControls ;
using System.Web .UI.WebControls .WebParts ;
using System.Xml .Linq ;

public class BEClass
{
private string uname;
private string upassword;
public string_uname{}
{
get{return uname;}
set {uname=value;}
}
public string_upassword{}
{
get{retrun upassword;}
set{upassword=value;}

}
}

Regards,
Sudheep.



Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 10/11/2011 [Member] Bronze | Points: 50

Resolved

Hi,

update your class as below
public class BEClass 

{
private string uname;
private string upassword;

public string string_uname
{
get
{
return uname;
}
set
{
uname=value;
}
}
public string string_upassword
{
get
{
return upassword;
}
set
{
upassword=value;
}

}
}

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Walia_jagwinder on: 10/11/2011 [Member] Starter | Points: 25

public string_uname{}

Remove these extra curly braces

One person's data is another person's program.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 10/11/2011 [Member] Starter | Points: 25

simply you could use
using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration ;
using System.Data ;
using System.Web ;
using System.Web .UI ;
using System.Web .UI.HtmlControls ;
using System.Web .UI.WebControls ;
using System.Web .UI.WebControls .WebParts ;
using System.Xml .Linq ;

public class BEClass
{
public string_uname{ get;set; }
public string _upassword { get;set; }
}

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 10/11/2011 [Member] Starter | Points: 25

Hi,

Thx for rectifying my error.I have the error under the login page button.for eg: like it will shows the error as

Error 7 Invalid expression term ')'.Here i am posting the full length of code.please do the needful.

using System;
using System.IO ;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration ;


namespace loginpage
{
public partial class Loginform : Form
{
DataTable dt=new DataTable ();
ErrorProvider ep=new ErrorProvider ();
BEClass being = new BEClass();
DALClass dac = new DALClass();

private void Loginform_Load(object sender, EventArgs e)
{
this .BackColor =System.Drawing.Color.DarkBlue ;



}

private void txt_username_Validating(object sender, CancelEventArgs e)
{
if(txt_username.Text.Trim ()=="")
{
ep.SetError(txt_username, "UserName is Required");
e.Cancel = true;
return;
}
ep.SetError (txt_username ,"");
}

private void btn_reset_Click(object sender, EventArgs e)
{
txt_username .Text ="";
txt_password.Text ="";
}

private void txt_password_Validating(object sender, CancelEventArgs e)
{
if(txt_password .Text .Trim ().Length <5)
{
ep.SetError(txt_password, "password is Required");
e.Cancel = true;
return;
}
ep.SetError (txt_password ,"");
}

private void btn_login_Click(object sender, EventArgs e)
{
string uname = txt_username.Text;
string upassword = txt_password.Text;
if(txt_username .Text.Length !=0 &&txt_password .Text .Length !=0)
{
dt table = dac.LoginForm(uname, upassword);
if(dt table .rows.count > 0)
{



}





}

public Loginform()
{



}





private void btn_reset_Click(object sender, EventArgs e)
{
txt_username.Text = "";
txt_password.Text = "";
}








}
}



Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 10/11/2011 [Member] Bronze | Points: 25

Hi,

you missed one cloding brace '}' in the method private void btn_login_Click, add brace and try again. if you are getting any error please let us know.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 10/11/2011 [Member] Starter | Points: 25

Hi,

one error is rectified that one closing braces.again it was showing the four errors.like
Error 4 ) expected
Error 5 ; expected
Error 6 Invalid expression term ')'
Error 7 ; expected
All these four errors are pointing to this particular line of code and the code of line is-if(dt table.rows.count > 0) .I think the error is when i am type dttable.in intellicesus it shows dt only dont table.rows.count this one.please do the needful.




if(dt table.rows.count > 0)

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 10/11/2011 [Member] Starter | Points: 50

Resolved

dt table is not a valid identifier
use dt as I could see you have declared dt
if(dt.rows.count > 0)

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 10/11/2011 [Member] Starter | Points: 25

Hi,

Thx for rectifying my problem.I have one query after the if(dt.rows.count > 0).it will goes to the database and validate the username.If the username is available in the database.it will direct the form into homepage.cs.otherwise it shows the message as "login failed" .for this i am applied a stupid code for this i don't no whether it is working or not but it will shows the error at response.i am using the code for redirecting the page as response.redirect("homepage.cs"); .is it valid code.can u please solve the problem.please do the needful.

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 10/11/2011 [Member] Starter | Points: 25

You have redirect to an aspx page or html file not the code file

Response.Redirect("homepage.aspx")

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 10/11/2011 [Member] Starter | Points: 25

Hi,

I am currently developing windows applications.what ever your giving the code it won't come.the login page was developed by windows applications and not on asp.net.

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 10/11/2011 [Member] Starter | Points: 25

I thought you are using asp.net as you have written response .redirect
In case of windows application
Try to create a new instance of your homepage and call the show method and hide the login form

if homepage is the name of your form
homepage  hp=new homepage ();

hp.show();
this.hide();

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 10/11/2011 [Member] Starter | Points: 25

Hi,

If i wrote the code.it will shows error.what can i do for rectifying this error.the error is pointing like this.
Error 5 Expected class, delegate, enum, interface, or struct.The error part is underlined.please find
private void btn_reset_Click(object sender, EventArgs e)
{
txt_username.Text = "";
txt_password.Text = "";
}

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response


Found interesting? Add this to: