顯示具有 TextBox 標籤的文章。 顯示所有文章
顯示具有 TextBox 標籤的文章。 顯示所有文章

2014年7月13日 星期日

[RESOLVED] add dropdown and textboxes to a dictionary collection


Hello guys,


I am using the approach to be able to iterate through the textboxes and dropdow list on a page



public static IEnumerable GetAllControls(Control parent)
{
if(null == parent) return null;

return new Control[] { parent }.Union(parent.Controls.OfType().SelectMany(child => GetAllControls(child));
}



foreach(DropDownList list in GetAllControls(this).OfType())
{
//TODO: add values to dictionary collections and append to session object
}

Now, after the loop and getting the values, I need to be able to store the droplist list ids and values into a sesion to be available elsewhere in the application.


Please help.



Thanks



untested, but something like


Dictionary data = new Dictionary();

foreach(DropDownList list in GetAllControls(this).OfType())
{
data.Add (list.ID, list.Items);
}

Session["DropDownData"] = data;


[RESOLVED] User Login????


i have four pages asp.net (c#)


(1) Login Page (2) MainMenu1   (3) MainMenu2 (4) MainMenu3


i also have sql database name "mydatabase" have three tables 


(1) Student (2) Teacher   (3) Admin


Login page contain 2 textboxes (  textbox1 for username,  textbox2 for password) and login button


i want when login button is pressed then check (match) username and password in three tables (Student ,Teacher ,Admin)


*if user is Student then page MainMenu1 is open


*if user is Teacher then page MainMenu2 is open


*if user is Admin then page MainMenu3 is open


plzzzzzz help me?????



Ok, post your code.  I think it would be nothing more than code behind visibility statements based on


if (!User.IsInRole == "Student") 
{
Menu1.Visibility = hidden;
}
else
{
Menu1.Visibility = visible;
}



At what stage are you?  Are you in the process of setting up the databases / tables? Or are you having to work with pre-existing tables?


Because if you are just starting, then the suggestion of bbcompent1 is a slick way to do it.  When each user is created, you would want a bit of code-behind to assign that user to one of the three Roles.


Then you probably only only need the tables that come with the asp.net membership, no need to add separate tables for the students, teachers, and admin.


And you only need one page for the menus -- not three -- just showing or hiding them as suggested.


[RESOLVED] How accept email format in asp.net?


Accept valid email format in asp.net


I am using following code



But this one 


I am enter data Anil@gmail.hhh this one also Accepting,It can accept only
Anil@gmail.com format



Hello Anil,


Try below regex expression, assuming you want only gmail account validation


^\w+([-+.']\w+)*@(?:GMAIL|gmail).com



i want all address



Let me tell you one thing, no matter what you do , end user can send invalid email ID.You can go through below reference for types of regex expressions , but then again , some loophole will be there:


http://regexlib.com/Search.aspx?k=email&AspxAutoDetectCookieSupport=1




Hi,




ANILBABU


i want all address


I agree with Asim there are thousands of domain and sub-domain now. Not possible to validate each and everyone of them.


Regards!


[RESOLVED] How Can we Comments function on website


You see many website where Users can post their comments on web page like You tube and many others website have this function , and along with their comments also display their name and timing how I can do ?



There are two ways for implementing this:


1. Create a custom comment.


2. Integrate the other comment providers like facebook, google comment etc.





Please help me how to do ? I dont know about these what you told me.



Hi,




SACHIN2708


You see many website where Users can post their comments on web page like You tube and many others website have this function , and along with their comments also display their name and timing how I can do ?


There are different ways to get it done. Below are few articles that you might find useful.


Using Knockout.js :


Demo -
http://demo.techbrij.com/1119/facebook-wall-post-comment-knockout.php


Tutorial -
http://techbrij.com/facebook-wall-posts-comments-knockout-aspnet-webapi


Using Repeater Control : Tutorial  -http://dotprogramming.blogspot.com/2013/07/how-to-make-comment-box-in-aspnet.html


ASP.NET Forums Website Part 6 Add the New Comment Page  :
http://www.aspnettutorials.com/tutorials/advanced/forums-site-p6-asp4/


Hope it helps!


Best Regards!


[RESOLVED] Fliter


i fliter gridview


using textbox and serach button


SP:



"SELECT * FROM [addproject1] WHERE ([ProjectName] LIKE '%' + @ProjectName + '%')">


but how write textbox to SP





sudharsan perumal



fliter gridview


using textbox and serach button


SP:



"SELECT * FROM [addproject1] WHERE ([ProjectName] LIKE '%' + @ProjectName + '%')">


but how write textbox to SP





Like this


string conString = ConfigurationManager.ConnectionStrings["MyCon"].ToString(); //Give your connection string here
SqlConnection sqlcon = new SqlConnection(conString);
SqlCommand sqlcmd;
SqlDataAdapter da;
DataTable dt = new DataTable();
String query;
if(txtsearch.Text!="")
query = "SELECT * FROM [addproject1] WHERE ([ProjectName] LIKE '%'" + txtsearch.Text + "%'";
}
sqlcmd = new SqlCommand(query, sqlcon);
sqlcon.Open();
da = new SqlDataAdapter(sqlcmd);
dt.Clear();
da.Fill(dt);
Gridview1.Source=dt;
GridView1.DataBind();


they come search button code?





sudharsan perumal


they come search button code?


Yes,you should write that code in the search button click event..query the database with the textbox value and bind your gridview.



Hi 


Create stored procedure:


CREATE PROCEDURE searchGrid
@ProjectName NVARCHAR(100)
AS
SELECT * FROM [addproject1] WHERE [ProjectName] LIKE '%' + @ProjectName + '%'

Codebehind: Write this on button click


string conString = ConfigurationManager.ConnectionStrings["MyCon"].ToString();
SqlConnection sqlcon = new SqlConnection(conString);
SqlCommand sqlcmd;
SqlDataAdapter da;
DataTable dt = new DataTable();
sqlcmd = new SqlCommand("searchGrid", sqlcon);
sqlcmd.CommandType = CommandType.StoredProcedure;
sqlcmd.Parameters.AddWithValue("@ProjectName", "ValueFromTextBox");
sqlcon.Open();
da = new SqlDataAdapter(sqlcmd);
dt.Clear();
da.Fill(dt);
Gridview1.Source=dt;
GridView1.DataBind();



protected void Button1_Click(object sender, EventArgs e)

{

SqlConnection con = new SqlConnection("Data Source=DASATML-PC;Initial Catalog=sudharsan;Integrated Security=True");

//String query;

if (TextBox14.Text != "")

{

SqlCommand cmd = new SqlCommand("SELECT * FROM [addproject1] WHERE ([ProjectName] LIKE '%'" + TextBox14.Text + "%'", con);

DataTable dt = new DataTable();


con.Open();

SqlDataAdapter da = new SqlDataAdapter(cmd);

con.Close();

dt.Clear();

da.Fill(dt);                                                                        ERROR:Incorrect syntax near 'java'.

Unclosed quotation mark after the character string        





GridView1.DataSource = dt;

GridView1.DataBind();

}

}


[RESOLVED] How to get new value from text-box in updating profile.??


Hi friends I designed webpage where people can login and after login they will be in profile page and on Profile page where Suppose these information is showing


First Name, Last Name , Email and these information are coming for database according to session


so on profile page there is Edit button when some one click on this so new page will be open where there is Coloumn


First Name:


Last Name:


Email :


and in these coloumn information are showing  which is coming from Profile page because on new page I set some coding so it takes information according to session from profile page problem is now suppose on new page when I am changing information and click
on Save button so information is not changing because text box is taking same value which is coming from profile page .


in short when you open page and some value are showing in text box and you can remove that value and fill new value and save on button so new value is not taking because in text box already value is filled so how I will referesh or do something else that
previous value can be vanish and new value can be taken in text box when I click on save button.



Make sure you are only loading the textboxes from the database when NOT ISPOSTBACK.  On the save button click you should then be able to save the new values in the textboxes to the database.



Yes Joy is right, load the text box in if(!isPostBack) and also have you written the Stored Procedure to update the profile as well?




Hi,




SACHIN2708



First Name, Last Name , Email and these information are coming for database according to session


so on profile page there is Edit button when some one click on this so new page will be open where there is Coloumn





Refer to the code:


    protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
//Load values from session to TextBoxes
//For example...
TextBox1.Text = Session["fname"].ToString();
TextBox2.Text = Session["lname"].ToString();
TextBox3.Text = Session["email"].ToString();
}
}

Hope it helps!


Best Regards!



Thanks a lot it works now,



use page not postback in page load event.


if(!Page.isPostBack)
{
// your code
}




[RESOLVED] add dropdown and textboxes to a dictionary collection


Hello guys,


I am using the approach to be able to iterate through the textboxes and dropdow list on a page



public static IEnumerable GetAllControls(Control parent)
{
if(null == parent) return null;

return new Control[] { parent }.Union(parent.Controls.OfType().SelectMany(child => GetAllControls(child));
}



foreach(DropDownList list in GetAllControls(this).OfType())
{
//TODO: add values to dictionary collections and append to session object
}

Now, after the loop and getting the values, I need to be able to store the droplist list ids and values into a sesion to be available elsewhere in the application.


Please help.



Thanks



untested, but something like


Dictionary data = new Dictionary();

foreach(DropDownList list in GetAllControls(this).OfType())
{
data.Add (list.ID, list.Items);
}

Session["DropDownData"] = data;


[RESOLVED] User Login????


i have four pages asp.net (c#)


(1) Login Page (2) MainMenu1   (3) MainMenu2 (4) MainMenu3


i also have sql database name "mydatabase" have three tables 


(1) Student (2) Teacher   (3) Admin


Login page contain 2 textboxes (  textbox1 for username,  textbox2 for password) and login button


i want when login button is pressed then check (match) username and password in three tables (Student ,Teacher ,Admin)


*if user is Student then page MainMenu1 is open


*if user is Teacher then page MainMenu2 is open


*if user is Admin then page MainMenu3 is open


plzzzzzz help me?????



Ok, post your code.  I think it would be nothing more than code behind visibility statements based on


if (!User.IsInRole == "Student") 
{
Menu1.Visibility = hidden;
}
else
{
Menu1.Visibility = visible;
}



At what stage are you?  Are you in the process of setting up the databases / tables? Or are you having to work with pre-existing tables?


Because if you are just starting, then the suggestion of bbcompent1 is a slick way to do it.  When each user is created, you would want a bit of code-behind to assign that user to one of the three Roles.


Then you probably only only need the tables that come with the asp.net membership, no need to add separate tables for the students, teachers, and admin.


And you only need one page for the menus -- not three -- just showing or hiding them as suggested.


[RESOLVED] How accept email format in asp.net?


Accept valid email format in asp.net


I am using following code



But this one 


I am enter data Anil@gmail.hhh this one also Accepting,It can accept only
Anil@gmail.com format



Hello Anil,


Try below regex expression, assuming you want only gmail account validation


^\w+([-+.']\w+)*@(?:GMAIL|gmail).com



i want all address



Let me tell you one thing, no matter what you do , end user can send invalid email ID.You can go through below reference for types of regex expressions , but then again , some loophole will be there:


http://regexlib.com/Search.aspx?k=email&AspxAutoDetectCookieSupport=1




Hi,




ANILBABU


i want all address


I agree with Asim there are thousands of domain and sub-domain now. Not possible to validate each and everyone of them.


Regards!


[RESOLVED] How Can we Comments function on website


You see many website where Users can post their comments on web page like You tube and many others website have this function , and along with their comments also display their name and timing how I can do ?



There are two ways for implementing this:


1. Create a custom comment.


2. Integrate the other comment providers like facebook, google comment etc.





Please help me how to do ? I dont know about these what you told me.



Hi,




SACHIN2708


You see many website where Users can post their comments on web page like You tube and many others website have this function , and along with their comments also display their name and timing how I can do ?


There are different ways to get it done. Below are few articles that you might find useful.


Using Knockout.js :


Demo -
http://demo.techbrij.com/1119/facebook-wall-post-comment-knockout.php


Tutorial -
http://techbrij.com/facebook-wall-posts-comments-knockout-aspnet-webapi


Using Repeater Control : Tutorial  -http://dotprogramming.blogspot.com/2013/07/how-to-make-comment-box-in-aspnet.html


ASP.NET Forums Website Part 6 Add the New Comment Page  :
http://www.aspnettutorials.com/tutorials/advanced/forums-site-p6-asp4/


Hope it helps!


Best Regards!


[RESOLVED] Fliter


i fliter gridview


using textbox and serach button


SP:



"SELECT * FROM [addproject1] WHERE ([ProjectName] LIKE '%' + @ProjectName + '%')">


but how write textbox to SP





sudharsan perumal



fliter gridview


using textbox and serach button


SP:



"SELECT * FROM [addproject1] WHERE ([ProjectName] LIKE '%' + @ProjectName + '%')">


but how write textbox to SP





Like this


string conString = ConfigurationManager.ConnectionStrings["MyCon"].ToString(); //Give your connection string here
SqlConnection sqlcon = new SqlConnection(conString);
SqlCommand sqlcmd;
SqlDataAdapter da;
DataTable dt = new DataTable();
String query;
if(txtsearch.Text!="")
query = "SELECT * FROM [addproject1] WHERE ([ProjectName] LIKE '%'" + txtsearch.Text + "%'";
}
sqlcmd = new SqlCommand(query, sqlcon);
sqlcon.Open();
da = new SqlDataAdapter(sqlcmd);
dt.Clear();
da.Fill(dt);
Gridview1.Source=dt;
GridView1.DataBind();


they come search button code?





sudharsan perumal


they come search button code?


Yes,you should write that code in the search button click event..query the database with the textbox value and bind your gridview.



Hi 


Create stored procedure:


CREATE PROCEDURE searchGrid
@ProjectName NVARCHAR(100)
AS
SELECT * FROM [addproject1] WHERE [ProjectName] LIKE '%' + @ProjectName + '%'

Codebehind: Write this on button click


string conString = ConfigurationManager.ConnectionStrings["MyCon"].ToString();
SqlConnection sqlcon = new SqlConnection(conString);
SqlCommand sqlcmd;
SqlDataAdapter da;
DataTable dt = new DataTable();
sqlcmd = new SqlCommand("searchGrid", sqlcon);
sqlcmd.CommandType = CommandType.StoredProcedure;
sqlcmd.Parameters.AddWithValue("@ProjectName", "ValueFromTextBox");
sqlcon.Open();
da = new SqlDataAdapter(sqlcmd);
dt.Clear();
da.Fill(dt);
Gridview1.Source=dt;
GridView1.DataBind();



protected void Button1_Click(object sender, EventArgs e)

{

SqlConnection con = new SqlConnection("Data Source=DASATML-PC;Initial Catalog=sudharsan;Integrated Security=True");

//String query;

if (TextBox14.Text != "")

{

SqlCommand cmd = new SqlCommand("SELECT * FROM [addproject1] WHERE ([ProjectName] LIKE '%'" + TextBox14.Text + "%'", con);

DataTable dt = new DataTable();


con.Open();

SqlDataAdapter da = new SqlDataAdapter(cmd);

con.Close();

dt.Clear();

da.Fill(dt);                                                                        ERROR:Incorrect syntax near 'java'.

Unclosed quotation mark after the character string        





GridView1.DataSource = dt;

GridView1.DataBind();

}

}


[RESOLVED] How to get new value from text-box in updating profile.??


Hi friends I designed webpage where people can login and after login they will be in profile page and on Profile page where Suppose these information is showing


First Name, Last Name , Email and these information are coming for database according to session


so on profile page there is Edit button when some one click on this so new page will be open where there is Coloumn


First Name:


Last Name:


Email :


and in these coloumn information are showing  which is coming from Profile page because on new page I set some coding so it takes information according to session from profile page problem is now suppose on new page when I am changing information and click
on Save button so information is not changing because text box is taking same value which is coming from profile page .


in short when you open page and some value are showing in text box and you can remove that value and fill new value and save on button so new value is not taking because in text box already value is filled so how I will referesh or do something else that
previous value can be vanish and new value can be taken in text box when I click on save button.



Make sure you are only loading the textboxes from the database when NOT ISPOSTBACK.  On the save button click you should then be able to save the new values in the textboxes to the database.



Yes Joy is right, load the text box in if(!isPostBack) and also have you written the Stored Procedure to update the profile as well?




Hi,




SACHIN2708



First Name, Last Name , Email and these information are coming for database according to session


so on profile page there is Edit button when some one click on this so new page will be open where there is Coloumn





Refer to the code:


    protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
//Load values from session to TextBoxes
//For example...
TextBox1.Text = Session["fname"].ToString();
TextBox2.Text = Session["lname"].ToString();
TextBox3.Text = Session["email"].ToString();
}
}

Hope it helps!


Best Regards!



Thanks a lot it works now,



use page not postback in page load event.


if(!Page.isPostBack)
{
// your code
}




[RESOLVED] add dropdown and textboxes to a dictionary collection


Hello guys,


I am using the approach to be able to iterate through the textboxes and dropdow list on a page



public static IEnumerable GetAllControls(Control parent)
{
if(null == parent) return null;

return new Control[] { parent }.Union(parent.Controls.OfType().SelectMany(child => GetAllControls(child));
}



foreach(DropDownList list in GetAllControls(this).OfType())
{
//TODO: add values to dictionary collections and append to session object
}

Now, after the loop and getting the values, I need to be able to store the droplist list ids and values into a sesion to be available elsewhere in the application.


Please help.



Thanks



untested, but something like


Dictionary data = new Dictionary();

foreach(DropDownList list in GetAllControls(this).OfType())
{
data.Add (list.ID, list.Items);
}

Session["DropDownData"] = data;


[RESOLVED] User Login????


i have four pages asp.net (c#)


(1) Login Page (2) MainMenu1   (3) MainMenu2 (4) MainMenu3


i also have sql database name "mydatabase" have three tables 


(1) Student (2) Teacher   (3) Admin


Login page contain 2 textboxes (  textbox1 for username,  textbox2 for password) and login button


i want when login button is pressed then check (match) username and password in three tables (Student ,Teacher ,Admin)


*if user is Student then page MainMenu1 is open


*if user is Teacher then page MainMenu2 is open


*if user is Admin then page MainMenu3 is open


plzzzzzz help me?????



Ok, post your code.  I think it would be nothing more than code behind visibility statements based on


if (!User.IsInRole == "Student") 
{
Menu1.Visibility = hidden;
}
else
{
Menu1.Visibility = visible;
}



At what stage are you?  Are you in the process of setting up the databases / tables? Or are you having to work with pre-existing tables?


Because if you are just starting, then the suggestion of bbcompent1 is a slick way to do it.  When each user is created, you would want a bit of code-behind to assign that user to one of the three Roles.


Then you probably only only need the tables that come with the asp.net membership, no need to add separate tables for the students, teachers, and admin.


And you only need one page for the menus -- not three -- just showing or hiding them as suggested.


[RESOLVED] How accept email format in asp.net?


Accept valid email format in asp.net


I am using following code



But this one 


I am enter data Anil@gmail.hhh this one also Accepting,It can accept only
Anil@gmail.com format



Hello Anil,


Try below regex expression, assuming you want only gmail account validation


^\w+([-+.']\w+)*@(?:GMAIL|gmail).com



i want all address



Let me tell you one thing, no matter what you do , end user can send invalid email ID.You can go through below reference for types of regex expressions , but then again , some loophole will be there:


http://regexlib.com/Search.aspx?k=email&AspxAutoDetectCookieSupport=1




Hi,




ANILBABU


i want all address


I agree with Asim there are thousands of domain and sub-domain now. Not possible to validate each and everyone of them.


Regards!


[RESOLVED] How Can we Comments function on website


You see many website where Users can post their comments on web page like You tube and many others website have this function , and along with their comments also display their name and timing how I can do ?



There are two ways for implementing this:


1. Create a custom comment.


2. Integrate the other comment providers like facebook, google comment etc.





Please help me how to do ? I dont know about these what you told me.



Hi,




SACHIN2708


You see many website where Users can post their comments on web page like You tube and many others website have this function , and along with their comments also display their name and timing how I can do ?


There are different ways to get it done. Below are few articles that you might find useful.


Using Knockout.js :


Demo -
http://demo.techbrij.com/1119/facebook-wall-post-comment-knockout.php


Tutorial -
http://techbrij.com/facebook-wall-posts-comments-knockout-aspnet-webapi


Using Repeater Control : Tutorial  -http://dotprogramming.blogspot.com/2013/07/how-to-make-comment-box-in-aspnet.html


ASP.NET Forums Website Part 6 Add the New Comment Page  :
http://www.aspnettutorials.com/tutorials/advanced/forums-site-p6-asp4/


Hope it helps!


Best Regards!


[RESOLVED] Fliter


i fliter gridview


using textbox and serach button


SP:



"SELECT * FROM [addproject1] WHERE ([ProjectName] LIKE '%' + @ProjectName + '%')">


but how write textbox to SP





sudharsan perumal



fliter gridview


using textbox and serach button


SP:



"SELECT * FROM [addproject1] WHERE ([ProjectName] LIKE '%' + @ProjectName + '%')">


but how write textbox to SP





Like this


string conString = ConfigurationManager.ConnectionStrings["MyCon"].ToString(); //Give your connection string here
SqlConnection sqlcon = new SqlConnection(conString);
SqlCommand sqlcmd;
SqlDataAdapter da;
DataTable dt = new DataTable();
String query;
if(txtsearch.Text!="")
query = "SELECT * FROM [addproject1] WHERE ([ProjectName] LIKE '%'" + txtsearch.Text + "%'";
}
sqlcmd = new SqlCommand(query, sqlcon);
sqlcon.Open();
da = new SqlDataAdapter(sqlcmd);
dt.Clear();
da.Fill(dt);
Gridview1.Source=dt;
GridView1.DataBind();


they come search button code?





sudharsan perumal


they come search button code?


Yes,you should write that code in the search button click event..query the database with the textbox value and bind your gridview.



Hi 


Create stored procedure:


CREATE PROCEDURE searchGrid
@ProjectName NVARCHAR(100)
AS
SELECT * FROM [addproject1] WHERE [ProjectName] LIKE '%' + @ProjectName + '%'

Codebehind: Write this on button click


string conString = ConfigurationManager.ConnectionStrings["MyCon"].ToString();
SqlConnection sqlcon = new SqlConnection(conString);
SqlCommand sqlcmd;
SqlDataAdapter da;
DataTable dt = new DataTable();
sqlcmd = new SqlCommand("searchGrid", sqlcon);
sqlcmd.CommandType = CommandType.StoredProcedure;
sqlcmd.Parameters.AddWithValue("@ProjectName", "ValueFromTextBox");
sqlcon.Open();
da = new SqlDataAdapter(sqlcmd);
dt.Clear();
da.Fill(dt);
Gridview1.Source=dt;
GridView1.DataBind();



protected void Button1_Click(object sender, EventArgs e)

{

SqlConnection con = new SqlConnection("Data Source=DASATML-PC;Initial Catalog=sudharsan;Integrated Security=True");

//String query;

if (TextBox14.Text != "")

{

SqlCommand cmd = new SqlCommand("SELECT * FROM [addproject1] WHERE ([ProjectName] LIKE '%'" + TextBox14.Text + "%'", con);

DataTable dt = new DataTable();


con.Open();

SqlDataAdapter da = new SqlDataAdapter(cmd);

con.Close();

dt.Clear();

da.Fill(dt);                                                                        ERROR:Incorrect syntax near 'java'.

Unclosed quotation mark after the character string        





GridView1.DataSource = dt;

GridView1.DataBind();

}

}


[RESOLVED] How to get new value from text-box in updating profile.??


Hi friends I designed webpage where people can login and after login they will be in profile page and on Profile page where Suppose these information is showing


First Name, Last Name , Email and these information are coming for database according to session


so on profile page there is Edit button when some one click on this so new page will be open where there is Coloumn


First Name:


Last Name:


Email :


and in these coloumn information are showing  which is coming from Profile page because on new page I set some coding so it takes information according to session from profile page problem is now suppose on new page when I am changing information and click
on Save button so information is not changing because text box is taking same value which is coming from profile page .


in short when you open page and some value are showing in text box and you can remove that value and fill new value and save on button so new value is not taking because in text box already value is filled so how I will referesh or do something else that
previous value can be vanish and new value can be taken in text box when I click on save button.



Make sure you are only loading the textboxes from the database when NOT ISPOSTBACK.  On the save button click you should then be able to save the new values in the textboxes to the database.



Yes Joy is right, load the text box in if(!isPostBack) and also have you written the Stored Procedure to update the profile as well?




Hi,




SACHIN2708



First Name, Last Name , Email and these information are coming for database according to session


so on profile page there is Edit button when some one click on this so new page will be open where there is Coloumn





Refer to the code:


    protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
//Load values from session to TextBoxes
//For example...
TextBox1.Text = Session["fname"].ToString();
TextBox2.Text = Session["lname"].ToString();
TextBox3.Text = Session["email"].ToString();
}
}

Hope it helps!


Best Regards!



Thanks a lot it works now,



use page not postback in page load event.


if(!Page.isPostBack)
{
// your code
}




[RESOLVED] add dropdown and textboxes to a dictionary collection


Hello guys,


I am using the approach to be able to iterate through the textboxes and dropdow list on a page



public static IEnumerable GetAllControls(Control parent)
{
if(null == parent) return null;

return new Control[] { parent }.Union(parent.Controls.OfType().SelectMany(child => GetAllControls(child));
}



foreach(DropDownList list in GetAllControls(this).OfType())
{
//TODO: add values to dictionary collections and append to session object
}

Now, after the loop and getting the values, I need to be able to store the droplist list ids and values into a sesion to be available elsewhere in the application.


Please help.



Thanks



untested, but something like


Dictionary data = new Dictionary();

foreach(DropDownList list in GetAllControls(this).OfType())
{
data.Add (list.ID, list.Items);
}

Session["DropDownData"] = data;


[RESOLVED] User Login????


i have four pages asp.net (c#)


(1) Login Page (2) MainMenu1   (3) MainMenu2 (4) MainMenu3


i also have sql database name "mydatabase" have three tables 


(1) Student (2) Teacher   (3) Admin


Login page contain 2 textboxes (  textbox1 for username,  textbox2 for password) and login button


i want when login button is pressed then check (match) username and password in three tables (Student ,Teacher ,Admin)


*if user is Student then page MainMenu1 is open


*if user is Teacher then page MainMenu2 is open


*if user is Admin then page MainMenu3 is open


plzzzzzz help me?????



Ok, post your code.  I think it would be nothing more than code behind visibility statements based on


if (!User.IsInRole == "Student") 
{
Menu1.Visibility = hidden;
}
else
{
Menu1.Visibility = visible;
}



At what stage are you?  Are you in the process of setting up the databases / tables? Or are you having to work with pre-existing tables?


Because if you are just starting, then the suggestion of bbcompent1 is a slick way to do it.  When each user is created, you would want a bit of code-behind to assign that user to one of the three Roles.


Then you probably only only need the tables that come with the asp.net membership, no need to add separate tables for the students, teachers, and admin.


And you only need one page for the menus -- not three -- just showing or hiding them as suggested.