Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have 2 pages mainpage & second page
i also 3checkboxes, 6 textboxes and one button on mainpage plus a textblock on second page
the textboxes take in integers



C#
private void ChkBox_CheckedChanged(object sender, EventArgs e)
{
private void CheckBox1_CheckedChanged(object sender, EventArgs e)
{if (checkbox1.Ischecked == true){
soln1 = textbox1.text * textbox2.text;}
else {
soln1=0;}
}
private void CheckBox2_CheckedChanged(object sender, EventArgs e)
{if (checkbox2.Ischecked == true){
soln2 = textbox3.text * textbox4.text;}
else{
soln2 = 0;}
}
private void CheckBox3_CheckedChanged(object sender, EventArgs e)
{ if (CheckBox3.Ischecked == true){
soln3 = textbox5.text * textbox6.text;}
else{
soln3 = 0;}
}

total = soln1 + soln2 + soln3;
}
}


i would like to pass the total to the second page on the textblock
how can i make this possible
thanks!
Posted
Updated 28-Jul-15 3:55am
v2
Comments
DamithSL 28-Jul-15 11:47am    
is this winform application?

1 solution

You can pass the result in a query string while using a button click and for best possible approach always encrypt the query string values and decrypt in your second page load event and then assign the value to the textbox shown in second page.

Let me know if you still have any doubts.

XML
<head>
    <script type="text/javascript">
var total=0;
var Total_store = document.getElementById("total_store");

        function OnChangeCheckbox (checkbox,var sol1,var sol2) {
            if (checkbox.checked) {
total=sol+sol2+total;
Total_store.value=total;
                alert ("The check box is checked.");
            }
            else {
//add negative test cases for uncheck to decrease the total count
                alert ("The check box is not checked.");
            }
        }


 var Total_store = document.getElementById("total_store");









    </script>
</head>
<body>
   
    
    <input id="checkbox1" onclick="OnChangeCheckbox (this,document.getElementById('txtbox1').value,document.getElementById('txtbox2').value)" id="myCheckbox" />


   
    
    <input id="checkbox2" onclick="OnChangeCheckbox (this,document.getElementById('txtbox2').value,document.getElementById('txtbox4').value)" id="myCheckbox" />


<input id="checkbox3" onclick="OnChangeCheckbox (this,document.getElementById('txtbox5').value,document.getElementById('txtbox6').value)" id="myCheckbox" />

<input type="hidden" id="total_store" name = "TotalStore" runat="server" />

 <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnsubmit_onclick()" />


<pre>

private void btnsubmit_onclick(sender s,eventargs e)
{
Response.Redirect("Webform2.aspx?value=" +
Convert.Tostring(total_score.value));

}

In page2 pageload event:
private void Page_Load(object sender, System.EventArgs e)
{
this.txtBox7.Text = Request.QueryString["Value"];

} 


For query string you can use encryption and decryption:
http://www.aspsnippets.com/Articles/Encrypt-and-Decrypt-QueryString-Parameter-Values-in-ASPNet-using-C-and-VBNet.aspx[^]

Please don't exactly copy and paste the code.This is an idea that i have mentioned with which you can proceed with.If you find useful please vote for the solution and accept which will make sure that this is a solution made for your question
 
Share this answer
 
v3
Comments
Shaddy Wiz Kay 28-Jul-15 10:01am    
help me with an example of what yu saying

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