5
Answers

How to round off the value and disabled the textbox inASPNET

Hi I want to round off the value which is in textbox, once value enter in textbox and before cursor moving to next field and also at the same time have to disable the textbox once round off get finished
Eg if i enter 456.667 in textbox means before the cursor move to next field it round off the value 456.667 to 457. Here i tried On value change event function.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script type ="text/javascript">
function tSpeedValue()
{
debugger;
var result = document.getElementById("<%=TextBox1.ClientID%>")
var result1 = result.tofixed(0);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" onchange="tSpeedValue"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" onchange="tSpeedValue1"></asp:TextBox>
</div>
</form>
</body>
</html>
Here what is my doubt is here i get the value and also rounded off the value. now my doubt is how to assign the round off value again to same textbox and also disable the textbox once round off. i have less knowledge in asp.net so only i ask this simple question as doubt. i tried my level best to explain the issue.Please any one understand my issue and help me to resolve this problem.
Answers (5)
0
Manas Mohapatra

Manas Mohapatra

NA 29.3k 3.3m 7y
can you tell, what is the value you are getting and value after rounding off. And what is the value displays in textbox after round off.
0
Sundar

Sundar

NA 9.6k 94.4k 7y
okay then check the following, did you enabled again the textbox ? is there any errors in browser side ? with the help of inspect element check that in browser ! then kindly let me know what's the error. I will guide you.
0
Sneha Dhandapani

Sneha Dhandapani

NA 383 36.4k 7y
Sundar actually I tried yesterday I get the value in textbox and round off the value but I can't able to assign the round off value again to that same textbox that is big problem
0
Sundar

Sundar

NA 9.6k 94.4k 7y
I will share the Logic, please try, 
 
 
In the Textbox blur event call the JavaScript Function to Round Off the value. After its done then make the textbox  disabled.
 
JavaScript  fuction  to round is available in google. Search. If you did not get let me know. 
0
Gokhul Varman

Gokhul Varman

NA 10.7k 9.4k 7y
Please refer the ink for detailed explanation:https://stackoverflow.com/questions/45574234/how-to-round-off-the-value-and-disabled-the-textbox-after-entering-the-value-in