Click here to Skip to main content
16,012,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<script type="text/javascript">

        function addthis(tid, val1) {
            if (tid.checked) {
                document.getElementById("resdiv").innerText = parseInt(document.getElementById("resdiv").value) + parseInt(val1);


            }
            else {
                document.getElementById("resdiv").innerText = parseInt(document.getElementById("resdiv").value) - parseInt(val1);
            }

        }


    </script>



<input type="text" id="resdiv" value="0" />

in code C#
i used

session["xyz"] = request.form["resdiv"]; which is not working
i used runat = "server" also but not working

any solution
Posted

<input type="text"  runat="server" id="resdiv" />

<script type="text/javascript">
 
function addthis(tid, val1) 
{
 if (tid.checked) 
  {
  document.getElementById("resdiv").innerHTML = parseInt(document.getElementById("resdiv").value) + parseInt(val1);
  }
 else
  {
   document.getElementById("resdiv").innerHTML = parseInt(document.getElementById("resdiv").value) - parseInt(val1);
  }
}
 

    </script>



Try This , it will work .
 
Share this answer
 
v4
hi
if you use runat="server"


then just u'll c that id directly in server side

like resdiv.value=

intellegency show you that id when you type that in code.

and one more thing is textbox values are access by value property in javascript not innertext


All the Best
 
Share this answer
 
Values you set on the client side (in JavaScript or via user interaction), even into submitted fields (i.e. runat=server), will only be available on the server side after a page submit. You must submit the main page form to re-run your server scripts.
 
Share this answer
 

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