ASP.NET decimal number localization handling issueValidate decimal numbers in JavaScript - IsNumeric()How to convert decimal to hexadecimal in JavaScriptHow can I format numbers as currency string in JavaScript?ASP.NET Web Site or ASP.NET Web Application?How do you handle multiple submit buttons in ASP.NET MVC Framework?Generating random whole numbers in JavaScript in a specific range?How to print a number with commas as thousands separators in JavaScriptGenerate random number between two numbers in JavaScriptFormat number to always show 2 decimal placesRound to at most 2 decimal places (only if necessary)
List, map function based on a condition
Why won't the Republicans use a superdelegate system like the DNC in their nomination process?
What evidence points to a long ō in the first syllable of nōscō's present-tense form?
What can I do to increase the amount of LEDs I can power with a pro micro?
Why do my bicycle brakes get worse and feel more 'squishy" over time?
Sums of binomial coefficients weighted by incomplete gamma
What is the prop for Thor's hammer (Mjölnir) made of?
How can I find an old paper when the usual methods fail?
What are the advantages of this gold finger shape?
Does the C++ standard guarantee that a failed insertion into an associative container will not modify the rvalue-reference argument?
Is Thieves' Cant a language?
Scam? Phone call from "Department of Social Security" asking me to call back
How can I find files in directories listed in a file?
Is there a name for the technique in songs/poems, where the rhyming pattern primes the listener for a certain line, which never comes?
Can someone with Extra Attack do a Commander Strike BEFORE he throws a net?
Suspension compromise for urban use
Good textbook for queueing theory and performance modeling
What is the opposite of "hunger level"?
What's the point of writing that I know will never be used or read?
Why aren't rockets built with truss structures inside their fuel & oxidizer tanks to increase structural strength?
Is this bar slide trick shown on Cheers real or a visual effect?
Locked room poison mystery!
Solving pricing problem heuristically in column generation algorithm for VRP
How do figure out how powerful I am, when my abilities far exceed my knowledge?
ASP.NET decimal number localization handling issue
Validate decimal numbers in JavaScript - IsNumeric()How to convert decimal to hexadecimal in JavaScriptHow can I format numbers as currency string in JavaScript?ASP.NET Web Site or ASP.NET Web Application?How do you handle multiple submit buttons in ASP.NET MVC Framework?Generating random whole numbers in JavaScript in a specific range?How to print a number with commas as thousands separators in JavaScriptGenerate random number between two numbers in JavaScriptFormat number to always show 2 decimal placesRound to at most 2 decimal places (only if necessary)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm writing a ASP.NET application (C# code, MySQL backend) that collect user data trough a form to be inserted into a SQL table using a stored procedure.
I'm using and wish to use DataSources
as long as I can.
The form field that generate the error is the following TextBox
(or any other TextBox
related to decimal value present into this form):
<asp:TableCell>
<asp:TextBox ID="_txtImportoIVA" ClientIDMode="Static" TextMode="Number" Step="0.01" Width="120px" runat="server" /> €
</asp:TableCell>
It's value feeds the following DataSource
togheter with values coming from similar widgets:
<asp:SqlDataSource
runat="server"
ID="_sdsDocumentiContabili"
ConnectionString="<%$ ConnectionStrings:sos_db %>"
ProviderName="<%$ ConnectionStrings:sos_db.ProviderName %>"
InsertCommandType="StoredProcedure"
InsertCommand="create_ndc_nlt"
OnInserted="_sdsDocumentiContabili_Inserted" OnInserting="_sdsDocumentiContabili_Inserting">
<InsertParameters>
<asp:ControlParameter ControlID="_txtImportoIVA" PropertyName="Text" Name="_importo_iva" Type="Double" />
<asp:Parameter Name="_id_ndc" Type="Int32" Direction="Output" />
</InsertParameters>
</asp:SqlDataSource>
When Insert
command is triggered the parameter:
<asp:ControlParameter ControlID="_txtImportoIVA" PropertyName="Text" Name="_importo_iva" Type="Double" />
is fed with a value that's correct only if the text inside the related TextBox
is an integer number. When If I provide a decimal value (using Italian localization) the value is obviously interpreted as integer because, I think, the decimal separator is not recognized. I tried to fix this by changing the form localization with culture specific parameters in Page
directive:
<%@ Page MasterPageFile="~/MasterPage.master" Language="C#" AutoEventWireup="true" CodeFile="NotaDiCreditoNLT.aspx.cs" Inherits="Intranet.NotaDiCreditoNLT" UICulture="it" Culture="it-IT" %>
But the result didn't change and the value keep being misinterpreted.
Please note that the TextBox
is filled up trough javascript code and not by direct user input (as explained below):
var _totaleIVA = Math.round(100 * _totaleIE * g_faliquotaiva) / 100;
var _txtImportoIVA = document.getElementById('_txtImportoIVA');
_txtImportoIVA.value = _totaleIVA;
the first line is a little workaround to truncate decimal to the second digit but can be omitted (the form will NOT work anyway).
Javascript
data handling in this form required also a little code-behind workaround because I wish some TextBoxes
to be readonly (removing this code will not fix this issue either):
// Workaround to use readonly javascript modified textboxes
private void SetAttributes()
_txtImportoIVA.Attributes.Add("readonly", "readonly");
protected void Page_Load(object sender, EventArgs e)
SetAttributes();
The only way I've been able to find to overcome this issue is to handle by code-behind the text-to-double translation (that was exactly what I was trying to avoid):
protected void _sdsDocumentiContabili_Inserting(object sender, SqlDataSourceCommandEventArgs e)
e.Command.Parameters["_importo_iva"].Value = Double.Parse(_txtImportoIVA.Text, CultureInfo.InvariantCulture);
Of course this requires related <asp:ControlParameter />
to be downgraded to trivial <asp:Parameter />
:
<asp:Parameter Name="_importo_iva" Type="Double" Direction="Input"/>
Is there a way to allow my form to correctly process decimal data without code-behind?
javascript mysql asp.net localization datasource
add a comment |
I'm writing a ASP.NET application (C# code, MySQL backend) that collect user data trough a form to be inserted into a SQL table using a stored procedure.
I'm using and wish to use DataSources
as long as I can.
The form field that generate the error is the following TextBox
(or any other TextBox
related to decimal value present into this form):
<asp:TableCell>
<asp:TextBox ID="_txtImportoIVA" ClientIDMode="Static" TextMode="Number" Step="0.01" Width="120px" runat="server" /> €
</asp:TableCell>
It's value feeds the following DataSource
togheter with values coming from similar widgets:
<asp:SqlDataSource
runat="server"
ID="_sdsDocumentiContabili"
ConnectionString="<%$ ConnectionStrings:sos_db %>"
ProviderName="<%$ ConnectionStrings:sos_db.ProviderName %>"
InsertCommandType="StoredProcedure"
InsertCommand="create_ndc_nlt"
OnInserted="_sdsDocumentiContabili_Inserted" OnInserting="_sdsDocumentiContabili_Inserting">
<InsertParameters>
<asp:ControlParameter ControlID="_txtImportoIVA" PropertyName="Text" Name="_importo_iva" Type="Double" />
<asp:Parameter Name="_id_ndc" Type="Int32" Direction="Output" />
</InsertParameters>
</asp:SqlDataSource>
When Insert
command is triggered the parameter:
<asp:ControlParameter ControlID="_txtImportoIVA" PropertyName="Text" Name="_importo_iva" Type="Double" />
is fed with a value that's correct only if the text inside the related TextBox
is an integer number. When If I provide a decimal value (using Italian localization) the value is obviously interpreted as integer because, I think, the decimal separator is not recognized. I tried to fix this by changing the form localization with culture specific parameters in Page
directive:
<%@ Page MasterPageFile="~/MasterPage.master" Language="C#" AutoEventWireup="true" CodeFile="NotaDiCreditoNLT.aspx.cs" Inherits="Intranet.NotaDiCreditoNLT" UICulture="it" Culture="it-IT" %>
But the result didn't change and the value keep being misinterpreted.
Please note that the TextBox
is filled up trough javascript code and not by direct user input (as explained below):
var _totaleIVA = Math.round(100 * _totaleIE * g_faliquotaiva) / 100;
var _txtImportoIVA = document.getElementById('_txtImportoIVA');
_txtImportoIVA.value = _totaleIVA;
the first line is a little workaround to truncate decimal to the second digit but can be omitted (the form will NOT work anyway).
Javascript
data handling in this form required also a little code-behind workaround because I wish some TextBoxes
to be readonly (removing this code will not fix this issue either):
// Workaround to use readonly javascript modified textboxes
private void SetAttributes()
_txtImportoIVA.Attributes.Add("readonly", "readonly");
protected void Page_Load(object sender, EventArgs e)
SetAttributes();
The only way I've been able to find to overcome this issue is to handle by code-behind the text-to-double translation (that was exactly what I was trying to avoid):
protected void _sdsDocumentiContabili_Inserting(object sender, SqlDataSourceCommandEventArgs e)
e.Command.Parameters["_importo_iva"].Value = Double.Parse(_txtImportoIVA.Text, CultureInfo.InvariantCulture);
Of course this requires related <asp:ControlParameter />
to be downgraded to trivial <asp:Parameter />
:
<asp:Parameter Name="_importo_iva" Type="Double" Direction="Input"/>
Is there a way to allow my form to correctly process decimal data without code-behind?
javascript mysql asp.net localization datasource
add a comment |
I'm writing a ASP.NET application (C# code, MySQL backend) that collect user data trough a form to be inserted into a SQL table using a stored procedure.
I'm using and wish to use DataSources
as long as I can.
The form field that generate the error is the following TextBox
(or any other TextBox
related to decimal value present into this form):
<asp:TableCell>
<asp:TextBox ID="_txtImportoIVA" ClientIDMode="Static" TextMode="Number" Step="0.01" Width="120px" runat="server" /> €
</asp:TableCell>
It's value feeds the following DataSource
togheter with values coming from similar widgets:
<asp:SqlDataSource
runat="server"
ID="_sdsDocumentiContabili"
ConnectionString="<%$ ConnectionStrings:sos_db %>"
ProviderName="<%$ ConnectionStrings:sos_db.ProviderName %>"
InsertCommandType="StoredProcedure"
InsertCommand="create_ndc_nlt"
OnInserted="_sdsDocumentiContabili_Inserted" OnInserting="_sdsDocumentiContabili_Inserting">
<InsertParameters>
<asp:ControlParameter ControlID="_txtImportoIVA" PropertyName="Text" Name="_importo_iva" Type="Double" />
<asp:Parameter Name="_id_ndc" Type="Int32" Direction="Output" />
</InsertParameters>
</asp:SqlDataSource>
When Insert
command is triggered the parameter:
<asp:ControlParameter ControlID="_txtImportoIVA" PropertyName="Text" Name="_importo_iva" Type="Double" />
is fed with a value that's correct only if the text inside the related TextBox
is an integer number. When If I provide a decimal value (using Italian localization) the value is obviously interpreted as integer because, I think, the decimal separator is not recognized. I tried to fix this by changing the form localization with culture specific parameters in Page
directive:
<%@ Page MasterPageFile="~/MasterPage.master" Language="C#" AutoEventWireup="true" CodeFile="NotaDiCreditoNLT.aspx.cs" Inherits="Intranet.NotaDiCreditoNLT" UICulture="it" Culture="it-IT" %>
But the result didn't change and the value keep being misinterpreted.
Please note that the TextBox
is filled up trough javascript code and not by direct user input (as explained below):
var _totaleIVA = Math.round(100 * _totaleIE * g_faliquotaiva) / 100;
var _txtImportoIVA = document.getElementById('_txtImportoIVA');
_txtImportoIVA.value = _totaleIVA;
the first line is a little workaround to truncate decimal to the second digit but can be omitted (the form will NOT work anyway).
Javascript
data handling in this form required also a little code-behind workaround because I wish some TextBoxes
to be readonly (removing this code will not fix this issue either):
// Workaround to use readonly javascript modified textboxes
private void SetAttributes()
_txtImportoIVA.Attributes.Add("readonly", "readonly");
protected void Page_Load(object sender, EventArgs e)
SetAttributes();
The only way I've been able to find to overcome this issue is to handle by code-behind the text-to-double translation (that was exactly what I was trying to avoid):
protected void _sdsDocumentiContabili_Inserting(object sender, SqlDataSourceCommandEventArgs e)
e.Command.Parameters["_importo_iva"].Value = Double.Parse(_txtImportoIVA.Text, CultureInfo.InvariantCulture);
Of course this requires related <asp:ControlParameter />
to be downgraded to trivial <asp:Parameter />
:
<asp:Parameter Name="_importo_iva" Type="Double" Direction="Input"/>
Is there a way to allow my form to correctly process decimal data without code-behind?
javascript mysql asp.net localization datasource
I'm writing a ASP.NET application (C# code, MySQL backend) that collect user data trough a form to be inserted into a SQL table using a stored procedure.
I'm using and wish to use DataSources
as long as I can.
The form field that generate the error is the following TextBox
(or any other TextBox
related to decimal value present into this form):
<asp:TableCell>
<asp:TextBox ID="_txtImportoIVA" ClientIDMode="Static" TextMode="Number" Step="0.01" Width="120px" runat="server" /> €
</asp:TableCell>
It's value feeds the following DataSource
togheter with values coming from similar widgets:
<asp:SqlDataSource
runat="server"
ID="_sdsDocumentiContabili"
ConnectionString="<%$ ConnectionStrings:sos_db %>"
ProviderName="<%$ ConnectionStrings:sos_db.ProviderName %>"
InsertCommandType="StoredProcedure"
InsertCommand="create_ndc_nlt"
OnInserted="_sdsDocumentiContabili_Inserted" OnInserting="_sdsDocumentiContabili_Inserting">
<InsertParameters>
<asp:ControlParameter ControlID="_txtImportoIVA" PropertyName="Text" Name="_importo_iva" Type="Double" />
<asp:Parameter Name="_id_ndc" Type="Int32" Direction="Output" />
</InsertParameters>
</asp:SqlDataSource>
When Insert
command is triggered the parameter:
<asp:ControlParameter ControlID="_txtImportoIVA" PropertyName="Text" Name="_importo_iva" Type="Double" />
is fed with a value that's correct only if the text inside the related TextBox
is an integer number. When If I provide a decimal value (using Italian localization) the value is obviously interpreted as integer because, I think, the decimal separator is not recognized. I tried to fix this by changing the form localization with culture specific parameters in Page
directive:
<%@ Page MasterPageFile="~/MasterPage.master" Language="C#" AutoEventWireup="true" CodeFile="NotaDiCreditoNLT.aspx.cs" Inherits="Intranet.NotaDiCreditoNLT" UICulture="it" Culture="it-IT" %>
But the result didn't change and the value keep being misinterpreted.
Please note that the TextBox
is filled up trough javascript code and not by direct user input (as explained below):
var _totaleIVA = Math.round(100 * _totaleIE * g_faliquotaiva) / 100;
var _txtImportoIVA = document.getElementById('_txtImportoIVA');
_txtImportoIVA.value = _totaleIVA;
the first line is a little workaround to truncate decimal to the second digit but can be omitted (the form will NOT work anyway).
Javascript
data handling in this form required also a little code-behind workaround because I wish some TextBoxes
to be readonly (removing this code will not fix this issue either):
// Workaround to use readonly javascript modified textboxes
private void SetAttributes()
_txtImportoIVA.Attributes.Add("readonly", "readonly");
protected void Page_Load(object sender, EventArgs e)
SetAttributes();
The only way I've been able to find to overcome this issue is to handle by code-behind the text-to-double translation (that was exactly what I was trying to avoid):
protected void _sdsDocumentiContabili_Inserting(object sender, SqlDataSourceCommandEventArgs e)
e.Command.Parameters["_importo_iva"].Value = Double.Parse(_txtImportoIVA.Text, CultureInfo.InvariantCulture);
Of course this requires related <asp:ControlParameter />
to be downgraded to trivial <asp:Parameter />
:
<asp:Parameter Name="_importo_iva" Type="Double" Direction="Input"/>
Is there a way to allow my form to correctly process decimal data without code-behind?
javascript mysql asp.net localization datasource
javascript mysql asp.net localization datasource
edited Mar 28 at 14:44
weirdgyn
asked Mar 27 at 11:52
weirdgynweirdgyn
3085 silver badges29 bronze badges
3085 silver badges29 bronze badges
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55376546%2fasp-net-decimal-number-localization-handling-issue%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55376546%2fasp-net-decimal-number-localization-handling-issue%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown