473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

doubts in session concept of asp.net

my requirement is in a default page, for login,there r 3 fields as userid,password n state(which is in a dropdown form).By default,all the texttexts of india should be displayed.so,when a user l choose any state,while login,he can see all the details of tht particular state,after going thro' each page.
for that, i hav e created one folder named as StateFiles which is common for all state folders,in each statefolders,the required text files r there.i have used the session,bt its showing exception,tht System.IO.DirectoryNotFoundException: Could not find a part of the path 'I:\IRSAssociation\StateFiles\AndhraPradesh.txt\Co ntactUs.txt'.
bt,actually i need the path to be 'I:\IRSAssociation\StateFiles\AndhraPradesh\Contac tUs.txt'. for the text to be displayed in ContactUs page
here m sending my code.
public partial class _Default : System.Web.UI.Page
{

string filePath = "StateFiles";
protected void Page_Load(object sender, EventArgs e)
{
Session["State"] = "State";
if (!Page.IsPostBack)
{
System.IO.StreamReader StreamReader1 = new System.IO.StreamReader(Server.MapPath("India/India.txt"));
ltrMsg.Text = StreamReader1.ReadToEnd();
StreamReader1.Close();
}

//GetMeetingsDetails();
//GetNewsDetails();
}

protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)
{

Session["State"] = ddlState.SelectedValue.ToString() + ".txt";

System.IO.StreamReader StreamReader1 = new System.IO.StreamReader(Server.MapPath(filePath + "/" + ddlState.SelectedValue.ToString() + "/" + "Default.txt"));
ltrMsg.Text = StreamReader1.ReadToEnd();
StreamReader1.Close();


}

protected void ibLogin_Click1(object sender, ImageClickEventArgs e)
{
MySqlConnection myConnection = new MySqlConnection(Details.GetConnectionString());
try
{
MySqlCommand myCommand = new MySqlCommand("usp_ValidateLogin", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.Parameters.Add(new MySqlParameter("?pUserId", MySqlDbType.VarChar)).Value = Convert.ToString(txtUserName.Text);
myCommand.Parameters.Add(new MySqlParameter("?pPassword", MySqlDbType.VarChar)).Value = Convert.ToString(txtPassword.Text);

DataSet dsUser = new DataSet();
MySqlDataAdapter mySqldaUser = new MySqlDataAdapter();
myConnection.Open();
mySqldaUser.SelectCommand = myCommand;
mySqldaUser.Fill(dsUser);

if (dsUser.Tables[0].Rows.Count != 0)
{
Session["user"] = txtUserName.Text.Trim();
Session["Login"] = "yes";
Response.Redirect("~/Main.aspx", false);
}
else
{
lblMessage.Visible = true;
}


}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
myConnection.Close();
}
//if (Session["State"].ToString() == "State")
string strState = Session["State"].ToString();
System.IO.StreamReader StreamReader1 = new System.IO.StreamReader(Server.MapPath(filePath + "/" + strState + "/" + "ContactUs.txt"));
ltrMsg.Text = StreamReader1.ReadToEnd();
StreamReader1.Close();

}
Sep 29 '07 #1
0 1095

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Jochen Daum | last post by:
Hi! I have a function in a lot of pages, which redirects to a new page, if a form has been submitted: if (!(defined("DEBUG_INSERT") && DEBUG_INSERT) && !(defined("DEBUG_UPDATE") &&...
5
by: jrefactors | last post by:
When we open a new web browser, all the windows that are open from that web browser belong to the same session. However, if we open a new web browser, then it will be different sessions. Is that...
3
by: AARON PECORARO | last post by:
I need to split apart my web application into multiple projects to allow it to be distributed in parts, but all of the projects need to work together (ie. they need to share session information)....
17
by: ranjeet.gupta | last post by:
Dear All Below are the few doubts which I got while studying about C 1. Is there any method in C by which we can process the entire string in one unit, 2. Does there exist any way to...
4
by: Kim Bach Petersen | last post by:
I would like to record user behavior data stored in session variables. Since the data is modified throughout each session it seemed obvious to store the data when the session terminates - using...
13
by: | last post by:
Simple question, I think... I'm storing an object in the Session object. In the code behind I read that object: trx = CType(Session("Transaction"), BOCSTransaction) If I change any...
6
by: Kermit Piper | last post by:
Hello, I thought this should be easy, but... all I want to do is set the value of this state drop-down based on a session var I'm getting back from a redirect (from the processing page): <%...
3
by: Alex D. | last post by:
Hi guys. I have been trying to create a new session from the server droping the exixting session using Session.Abandon but since the browser doesnt know that the session was abandoned it keeps...
43
by: davidkoree | last post by:
I mean not about cookie. Does it have something to do with operating system or browser plugin? I appreciate any help.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.