if (Session["F1"] != null && !string.IsNullOrEmpty(Convert.ToString(Session["F1"])))
{
TextBox1.Text = Convert.ToString(Session["F1"]);
}
else
{
TextBox1.Text = "Session is null or having no value";
}
it will give you better idea rather your Session["F1"] is null or not
Please Mark as Answer if find helpful -- Nasser -- Skype: maleknasser1
kp40
Member
5 Points
52 Posts
textBox filling from one page to another
May 21, 2012 05:09 PM|LINK
I'm moving from one page to another page. How can I add some info to a certian text box.
I treid below code, it didn't work
I move from page 1 to page 2
page 1:
Session["F1"] = f1;
page 2:
TextBox1.Text = (string)(Session["F1"]);
but it didn't work
UstesG
Contributor
2098 Points
449 Posts
Re: textBox filling from one page to another
May 21, 2012 05:13 PM|LINK
what didn't work? what was the error?
But don't expect me to do your job!
kp40
Member
5 Points
52 Posts
Re: textBox filling from one page to another
May 21, 2012 05:14 PM|LINK
I used label, certain text came. but it didn't put any text to textbox.
UstesG
Contributor
2098 Points
449 Posts
Re: textBox filling from one page to another
May 21, 2012 05:17 PM|LINK
on page 2 does session["f1"] have a value? put a break on page 1 where you are assigning the value. What si the value there?
But don't expect me to do your job!
kp40
Member
5 Points
52 Posts
Re: textBox filling from one page to another
May 21, 2012 05:20 PM|LINK
yes it has, f1 can put the value on label but textbox :(, very strange. I can't put break, then it doesn't go to page 2
venugopaldik...
Member
42 Points
24 Posts
Re: textBox filling from one page to another
May 21, 2012 05:44 PM|LINK
IT should work. Their is no error in the concept.
If you can, paste the code what you wrote? I can explain you ...
India.
velayudham
Member
37 Points
30 Posts
Re: textBox filling from one page to another
May 21, 2012 05:50 PM|LINK
you can get value via query string ... try query string it will help you..
Nasser Malik
Star
11260 Points
1731 Posts
Re: textBox filling from one page to another
May 21, 2012 05:53 PM|LINK
there is concept of crosse page posting in asp.net, By this we can achieve what you want
see code
First Page named as Page1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page1.aspx.cs" Inherits="WebApplication1.Page1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TxtShowOnNextPage" runat="server" /> <asp:Button ID="Button1" runat="server" Text="Next Page" PostBackUrl="Page2.aspx" /> </div> </form> </body> </html>Second Paged name as Page2.aspx
Code behind - Page2.aspx.cs
for further readings please see following articles
http://msdn.microsoft.com/en-us/library/ms178139.aspx
http://www.dotnetcurry.com/ShowArticle.aspx?ID=71
http://www.csharpaspnetarticles.com/2009/08/cross-page-posting-in-aspnet.html
Skype: maleknasser1
Nasser Malik
Star
11260 Points
1731 Posts
Re: textBox filling from one page to another
May 21, 2012 05:59 PM|LINK
Or you can try code on your second page.
if (Session["F1"] != null && !string.IsNullOrEmpty(Convert.ToString(Session["F1"]))) { TextBox1.Text = Convert.ToString(Session["F1"]); } else { TextBox1.Text = "Session is null or having no value"; }it will give you better idea rather your Session["F1"] is null or not
Skype: maleknasser1
AvikPeekayMa...
Member
13 Points
36 Posts
Re: textBox filling from one page to another
May 21, 2012 06:44 PM|LINK
In page 2 try this one....
TextBox1.Text =Session["F1"].ToString();