0

I'm calling a javascript function in a grid. Here is the code.

 <div style="width: 100%; float: left; margin-bottom: 10px;">
   <a href="#" onclick='<%# "ShowDetailPopup("+Eval("subscriberId").ToString()+","+Eval("Debt") +"," + Eval("Receivable") +","+
   Eval("LegalAmount") + "," + Eval("fullName").ToString() +")" %>'>Detay</a>
  </div>

Here is the js function.

function ShowDetailPopup(subscriberId, Debt, Receivable, LegalAmount, fullName) {
            var popupWindow = pcDocument.GetWindowByName("showDocumentWindow");
            pcDocument.ShowWindow(popupWindow);
            pcDocument.SetWindowContentUrl(popupWindow, '/WEB/Pages/DebtAndReceiveDocument.aspx?ID=' + subscriberId + "&Debt=" + Debt +
                "&Receivable=" + Receivable + "&LegalAmount=" + LegalAmount + "&fullName=" + fullName);
        }

Debt, Receivable and LegalAmount are all decimal fields. Example values:

Debt = 4,65
Receivable = 13,00
LegalAmount = 0

When I call function, the page renders like this.

 <a href="#" onclick='ShowDetailPopup(18069606,4,65,13,00,0,BILL GATES)'>Detay</a>

How can I correctly send the decimal values?

2
  • did you try using a dot? Commented Jan 21, 2015 at 9:59
  • @Vajura, No., I didn't put. Commented Jan 21, 2015 at 10:26

3 Answers 3

2

It seems that you have a different Culture set for client-side than on server-side. If you just want to replace the comma separator with a dot directly, try like this:

Eval("Debt")

will become

Eval("Debt").Replace(",", ".")
Sign up to request clarification or add additional context in comments.

Comments

1
decimal Debt = Convert.ToDecimal("4.65");

Eval("Debt") return 4.65 and voila.

You can have 4,56 only if you declared your variable as string, so your problem is at variable type.

Eval(decimal) or Eval(double) returns number with floating point having "." not ","

Comments

1

You might also want to do Eval("Debt").ToString("0.00"); or better still, this will solve both: Eval("Debt").ToString("F", CultureInfo.InvariantCulture)) so you always get two decimal places and a "." instead of a ","

I.e: 4 will be printed as 4.00 and something like 4,200,362.01 will be printed as 4200362.01

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.