You can put this
script
-tag to your
head
:
<script>
window.addEventListener("load", function() {
document.getElementById("<%= Button1.ClientID %>").addEventListener("click", function() {
var textbox1value = parseFloat(document.getElementById("<%= TextBox1.ClientID %>").value);
var textbox2value = parseFloat(document.getElementById("<%= TextBox2.ClientID %>").value);
document.getElementById("<%= TextBox3.ClientID %>").value = (textbox1value * textbox2value / 100).toString();
});
});
</script>
The "load" event listener makes sure that the function (passed as second argument) gets called when the page is loaded. The
<%= Button1.ClientID %>
evaluations (and the similar ones later) make sure that the script in the HTML response contains the correct IDs for the elements on the client side (their client-side ID is not necessarily their server-side ID). Then the "click" handler executes a function when the button is clicked,
parseFloat
converts the textbox values to floating-point numbers and then your operation is performed on these values and the result is put in
TextBox3
.