ASP.NET javascript. Put it in code behind or put it in .aspx file?

Posted by punkouter on Stack Overflow See other posts from Stack Overflow or by punkouter
Published on 2010-05-27T21:34:48Z Indexed on 2010/05/27 21:41 UTC
Read the original article Hit count: 182

Filed under:
|

Why do people put javascript in the code behind ? I think it is ugly to have 100 (see below) of these.... Is there some basic reasons that javascript must be in the code behind in some instances? And when it should in the aspx. ??

 // now we gotta recalc fields                 
            szCalcBenefitsTotal += "         CalcCostFromPct('" + tbSocialSecurityPercent3.ClientID + "', '" + tbSocialSecurity3.ClientID + "', '" + tbSalaryAdjusted3.ClientID + "');";
            szCalcBenefitsTotal += "         CalcCostFromPct('" + tbMedicarePercent3.ClientID + "', '" + tbMedicare3.ClientID + "', '" + tbSalaryAdjusted3.ClientID + "');";
            szCalcBenefitsTotal += "         CalcCostFromPct('" + tbHealthInsurancePercent3.ClientID + "', '" + tbHealthInsurance3.ClientID + "', '" + tbSalaryAdjusted3.ClientID + "');";
            szCalcBenefitsTotal += "         CalcCostFromPct('" + tbLifeInsurancePercent3.ClientID + "', '" + tbLifeInsurance3.ClientID + "', '" + tbSalaryAdjusted3.ClientID + "');";
            szCalcBenefitsTotal += "         CalcCostFromPct('" + tbVacationPercent3.ClientID + "', '" + tbVacation3.ClientID + "', '" + tbSalaryAdjusted3.ClientID + "');";
            szCalcBenefitsTotal += "         CalcCostFromPct('" + tbSickLeavePercent3.ClientID + "', '" + tbSickLeave3.ClientID + "', '" + tbSalaryAdjusted3.ClientID + "');";
            szCalcBenefitsTotal += "         CalcCostFromPct('" + tbRetirementPercent3.ClientID + "', '" + tbRetirement3.ClientID + "', '" + tbSalaryAdjusted3.ClientID + "');";

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript