Click here to Skip to main content
15,905,874 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i m facing problem in passing default1.aspx page values to default2.aspx page using javascript. what i m trying to do is when user clicks on submit button a confirmation appears that 'do u want to enter details' on clicking ok all the entered values passes to default2.aspx using javascript what i have done is as follows:
C#
function confirm1() {
    if (confirm('Are u sure??')) {
        window.open('Default2.aspx', 'mywin', 'height=400px width=500px locatio=no titlebar=0');
    }

and on my button click:
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "popup", "alert('Empid:'" + "@E_ID" + "is inssss'...');", true);

using this only popup a msgbox and on clicking ok new default2.aspx appers but empty . How to resolve the problem?
In short i want to pass all values from default1.aspx to default2.aspx using javascript function.
Posted
Comments
Thanks7872 1-Jul-13 2:58am    
Why you aimed at perticularly using javascript?
Rambo_Raja 1-Jul-13 3:03am    
what are the other options? can u please tell me the other good ones.?thnx...
jaideepsinh 1-Jul-13 3:07am    
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "popup", "alert('Empid:'" + '"YourVariable"' + "is inssss'...');", true);
Rambo_Raja 1-Jul-13 3:10am    
what? what do u mean?

Well,approach suggested above is pretty well.Further,you can pass values through query string after encryption.

C#
String temp = Encrypt (Textbox1.Text);//Text gets encrypted using any algorithm
Response.Redirect("Webform2.aspx?Value=" +temp);


To retrieve values on another end,

C#
if(Request.QueryString["Value"] != null)
{
txtBox1.Text = Decrypt(Request.QueryString["Value"].ToString());
}


You can refer to below link for Encryption decryption

Encrypt and Decrypt Data with C#[^]

Below link will explain alot about passing values.

How to: Pass Values Between ASP.NET Web Pages[^]

Regards..:)
 
Share this answer
 
v2
Comments
_Amy 1-Jul-13 3:29am    
+5!
Thanks7872 1-Jul-13 3:29am    
Thanks Amit.
Prasad Khandekar 1-Jul-13 4:00am    
My 5+. Encrypting is a really good suggestion.
Thanks7872 1-Jul-13 4:38am    
Thanks alot prasad...
Pass the values using querystring[^]. Try this:
JavaScript
function confirm1() {
    //Get the value from form and store it in variables.
    var ID = document.getElementById('YourID').value;
    var Name = document.getElementById('YourName').value;

    if (confirm('Are u sure??')) {
        window.open('Default2.aspx?ID='+ID+'&Name='+Name, 'mywin', 'height=400px width=500px locatio=no titlebar=0');
    }
}

Retrive it in Default2.aspx page. Please see this[^].


--Amit
 
Share this answer
 
Comments
Rambo_Raja 1-Jul-13 3:02am    
but isn't querystring is unsave as a sharp user can read all sensitive matter.
_Amy 1-Jul-13 3:14am    
Then do a postback and set the values in session. You can also use Properties or Cookies.
--Amit
Orcun Iyigun 1-Jul-13 3:17am    
If you do not them to be shown create a class to save the values and use Session to save them. Or if you do not want to use a class save each value to a separate Session. For more info please check: Sessions[^]
Thanks7872 1-Jul-13 3:18am    
↑voted. And as per the comment by OP,suggested another approach as suggesion.
_Amy 1-Jul-13 3:29am    
Thank you Rohan. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900