locked
Form entry AsInt() RRS feed

  • Question

  • User-1753299103 posted

    I have a form that is being picked up as follows:

    int mynumber=Request["number"].AsInt();
    

    However, If a number entered as 035 it's converted to 35 removing the preceeding "0". I need the entire number!

     

    Thanks

     

    Tuesday, August 6, 2013 4:44 PM

Answers

  • User379720387 posted

    035 is not an integer

    keep it as a string

    var mynumber=Request["number"];
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 6, 2013 4:51 PM
  • User281315223 posted

    If you want to store the value as "035", you'll need to store it as a String instead of an integer.

    Integers will ignore any leading zeroes when they are read and used by default, so this is completely normal behavior. Have you consider storing it as a String and when you need to actually grab the value, using the AsInt() method?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 6, 2013 5:21 PM

All replies

  • User379720387 posted

    035 is not an integer

    keep it as a string

    var mynumber=Request["number"];
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 6, 2013 4:51 PM
  • User281315223 posted

    If you want to store the value as "035", you'll need to store it as a String instead of an integer.

    Integers will ignore any leading zeroes when they are read and used by default, so this is completely normal behavior. Have you consider storing it as a String and when you need to actually grab the value, using the AsInt() method?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 6, 2013 5:21 PM