Passing value of string from one button click event to another

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2006
Posts: 1
Reputation: Neeraja is an unknown quantity at this point 
Solved Threads: 0
Neeraja Neeraja is offline Offline
Newbie Poster

Passing value of string from one button click event to another

 
0
  #1
Aug 16th, 2006
Hello All,
I have developed a web application that has one form with several text boxes and 2 buttons submit and next.

On clicking the next button, the old values in the text box gets cleared and gives way to enter new values in the text box.

In the "next" button click event i am trying to append the old values of the text box to the new values so that i can have the string value finally when i am clcking on the "submit" Button.

The problem here is everytime i click on the next button, the string which i have declared is having only the last value and not the appended one..

publicclass xxclass : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
.
.
public String s;
privatevoid Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

}
privatevoid ButtonSubmit_Click(object sender, System.EventArgs e)
{
//I want the value of s here
}
privatevoid ButtonNext_Click(object sender, System.EventArgs e)
{
 
 
Session["FName"] = TFName.Text;
Session["LName"] = TLName.Text;
 
 
s = s + "First Name :\n"; // The value of s is always the last value and is not appending.
s = s + Session["FName"];
s = s + "Last Name : \n";
s = s + Session["LName"];
Session["mykey"] = s.ToString();
 
 
 
}

Hope i am clear. Can anyone help me out with this.
Please note that i am new to this technology and hence help in simple words would be of great help to me
Neeraja
Last edited by tgreer; Aug 17th, 2006 at 8:30 pm. Reason: added code tags
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 47
Reputation: kedar_challa is an unknown quantity at this point 
Solved Threads: 1
kedar_challa's Avatar
kedar_challa kedar_challa is offline Offline
Light Poster

Re: Passing value of string from one button click event to another

 
0
  #2
Aug 17th, 2006
Hi Neeraja,

U need to retain the old value before updating the string 's'. Use the follwoing code.

  1. if(Session["mykey"] != null)
  2. s = Session["mykey"] as string;
  3.  
  4. s = s + "First Name :\n"; // The value of s is always the last value and is not appending.
  5. s = s + Session["FName"];
  6. s = s + "Last Name : \n";
  7. s = s + Session["LName"];
  8. Session["mykey"] = s.ToString();

Thanks,
Kedar.

Originally Posted by Neeraja
Hello All,
I have developed a web application that has one form with several text boxes and 2 buttons submit and next.

On clicking the next button, the old values in the text box gets cleared and gives way to enter new values in the text box.

In the "next" button click event i am trying to append the old values of the text box to the new values so that i can have the string value finally when i am clcking on the "submit" Button.

The problem here is everytime i click on the next button, the string which i have declared is having only the last value and not the appended one..

publicclass xxclass : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
.
.
public String s;
privatevoid Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

}
privatevoid ButtonSubmit_Click(object sender, System.EventArgs e)
{
//I want the value of s here
}
private
void ButtonNext_Click(object sender, System.EventArgs e)
{


Session["FName"] = TFName.Text;
Session["LName"] = TLName.Text;


s = s + "First Name :\n"; // The value of s is always the last value and is not appending.
s = s + Session["FName"];
s = s + "Last Name : \n";
s = s + Session["LName"];
Session["mykey"] = s.ToString();



}

Hope i am clear. Can anyone help me out with this.
Please note that i am new to this technology and hence help in simple words would be of great help to me
Neeraja
Last edited by tgreer; Aug 17th, 2006 at 8:31 pm. Reason: Added code tags.
Thanks,

KedarNath Challa
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Passing value of string from one button click event to another

 
0
  #3
Aug 17th, 2006
Please use the code tags when posting code. Thank you.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 1
Reputation: shubhadaamar is an unknown quantity at this point 
Solved Threads: 0
shubhadaamar shubhadaamar is offline Offline
Newbie Poster

Re: Passing value of string from one button click event to another

 
0
  #4
Nov 13th, 2007
can somebody help me???
I want to auto post the page through my python code
I want to read the page then enter values in text boxes & then submitting it. All thr python code
Is it possible through python
python is new for me
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC