| | |
Passing value of string from one button click event to another
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2006
Posts: 1
Reputation:
Solved Threads: 0
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..
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
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
Hi Neeraja,
U need to retain the old value before updating the string 's'. Use the follwoing code.
Thanks,
Kedar.
U need to retain the old value before updating the string 's'. Use the follwoing code.
ASP.NET Syntax (Toggle Plain Text)
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
}
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:31 pm. Reason: Added code tags.
Thanks,
KedarNath Challa
KedarNath Challa
![]() |
Similar Threads
- Button click event only working the second time (C#)
- Calling button-click events from different classes (Python)
- Click event >> window appears? (Python)
- Problem in displaying returned value from function (C#)
- Control button Click event (Visual Basic 4 / 5 / 6)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: checkbox as a itemtemplate in a datalist
- Next Thread: need some help with url qeury string with response.redirect
| Thread Tools | Search this Thread |
.net 3.5 ajax alltypeofvideos appliances asp asp.net bc30451 beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions control countryselector dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash formatdecimal formview gridview gudi iis javascript list listbox login microsoft mouse mssql nameisnotdeclared news novell numerical opera panelmasterpagebuttoncontrols problem radio redirect registration relationaldatabases reportemail save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos vista visualstudio vs2008 web webapplications webdevelopemnt webdevelopment webprogramming webservice wizard xsl youareanotmemberofthedebuggerusers






