我如何通过总计 [英] How Do I Pass The Total

查看:81
本文介绍了我如何通过总计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2页主页&第二页

i还有3个复选框,6个文本框和主页上的一个按钮以及第二页上的文本块

文本框采用整数







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



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希望将总数传递到文本块的第二页

我怎样才能做到这一点

谢谢!



i would like to pass the total to the second page on the textblock
how can i make this possible
thanks!

推荐答案

你可以在使用按钮时将结果传递给查询字符串单击并获得最佳方法始终加密查询字符串值并在第二页加载事件中解密,然后将值分配给第二页中显示的文本框。



让我知道你是否还有任何疑问。



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.

<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));

}



在第2页pageload事件:


In page2 pageload event:

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

} 





对于查询字符串,您可以使用加密和解密:

http:// www。 aspsnippets.com/Articles/Encrypt-and-Decrypt-QueryString-Parameter-Values-in-ASPNet-using-C-and-VBNet.aspx [ ^ ]



请不要完全复制并粘贴代码。这是我提到的一个你可以继续使用的想法。如果你觉得有用,请投票支持解决方案并接受这将确保这是为您的问题做出的解决方案



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


这篇关于我如何通过总计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆