javascript - ViewBag value returning wrong number -


i trying insert values viewbag input through javascript , dynamically creating value.

i call value of employeeid made controller

public string getemployeeid(out string idmethod) {         string ee_id = string.empty;         clientemployeesetupdefaults ee_setup = this.dbcontext.clientemployeesetupdefaults.firstordefault(c => c.clientid == globalvariables.client);         string nextidsuffix = string.empty;         idmethod = ee_setup.employeeidmethod;         switch (idmethod)         {             case idmethod.sequence:                 ee_id = nextemployeeid(ee_setup.employeeidnext, "", out nextidsuffix);                 break;             case idmethod.prefixplusseq:                 ee_id = nextemployeeid(ee_setup.employeeidnext, ee_setup.employeeidprefix, out nextidsuffix);                 break;         }         if (nextidsuffix != string.empty)         {             ee_setup.employeeidnext = nextidsuffix;             this.dbcontext.savechanges();         }         return ee_id; } 

with viewbag

@{ viewbag.title = "createprocess"; string employeeid = @viewbag.employeeid.tostring(); var logincode = @viewbag.logincode; } 

its inserted javascript

<script> $(document).ready(function () {     alert('doc ready happened ' + @employeeid + ' - ' + @logincode);     document.getelementbyid('logincode').value = @logincode;     document.getelementbyid('employeeids').value = @employeeid.tostring();  }); </script> 

i have debugged way through , each time on employeeid of 010015001 returns 2103809 regardless if pulls database dynamically or if hardcode value.

during process runs through method

public actionresult createprocess(string d, string p, string e, string c, string pp)     {         string method;         list<id_name> profiles = getavailableprofiles(p, d);         viewbag.profiles = profiles;         viewbag.logincode = getlogincode();         string eeid = getemployeeid(out method);         viewbag.employeeid = eeid.tostring();         viewbag.idmethod = method;         viewbag.selecteddepartment = d;         viewbag.selectedposition = p;         viewbag.selectedeeclass = c;         viewbag.selectedestatus = e;         viewbag.defaultprofile = profiles[0].id;         xxx.signon = this.dbcontext.xxx.where(obpt => obpt.tasktype == xxx.signon && obpt.setupid == profiles[0].id).firstordefault();         viewbag.signontask = signon.taskid;         return view();     } 

i can't figure out why return random number , why through of debugging shows correct 010015001 on refresh loads in bad number.

integers leading 0 in octal (base 8) notation.

010015001 (octal) = 2103809 (decimal)

if employeeid string contains integer number in decimal form, should strip leading zero:

string employeeid = @viewbag.employeeid.tostring().trimstart(new char[]{'0'}); 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -