User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 427,493 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,471 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 4022 | Replies: 3
Reply
Join Date: Aug 2006
Posts: 1
Reputation: Neeraja is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Neeraja Neeraja is offline Offline
Newbie Poster

Passing value of string from one button click event to another

  #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 7:30 pm. Reason: added code tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2005
Location: Mountain View, CA
Posts: 47
Reputation: kedar_challa is an unknown quantity at this point 
Rep Power: 3
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

  #2  
Aug 17th, 2006
Hi Neeraja,

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

if(Session["mykey"] != null)
      s = Session["mykey"] as string;
 
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();

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 7:31 pm. Reason: Added code tags.
Thanks,

KedarNath Challa
Reply With Quote  
Join Date: Dec 2004
Posts: 1,590
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 35
Colleague
tgreer tgreer is offline Offline
Made Her Cry

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

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

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

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 7:01 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC