Click here to Skip to main content
16,022,069 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I try to call <ajaxpro.ajaxmethod()> inside JavaScript; it's working fine on previous version like visual studio 2005 and visual studio 2008 but not working in visual studio 2017 (it's working in up to .net framework 4 not working in .net framework 4.5 ) how to solve this issue

What I have tried:

JavaScript
  function OnEmployeeChange(EmployeeList)
  {
      var empCode = EmployeeList.options[EmployeeList.selectedIndex].value
      
      EskanRyteHRMS.Personal_Transfer.SetEmployeeProperties(empCode, OnEmployeeChange_callback)
     // Personal_Transfer.SetEmployeeProperties(empCode, OnEmployeeChange_callback)
}

function OnEmployeeChange_callback(response)
{
    if (response != null)
    {
        var DataRow = response.value;
        
         var dlOldLocation = document.getElementById("<%=dlOldLocation.ClientID%>");
          var dlLocation = document.getElementById("<%=dlLocation.ClientID%>");             
        dlOldLocation.value = dlLocation.value = DataRow[4];

          var dlOldDepartment = document.getElementById("<%=dlOldDepartment.ClientID%>");
          var dlDepartment = document.getElementById("<%=dlDepartment.ClientID%>");
                                 
        dlDepartment.value = dlOldDepartment.value = DataRow[3];

        var dlOldReportTo = document.getElementById("<%=dlOldReportTo.ClientID%>");
        var dlReportTo = document.getElementById("<%=dlReportTo.ClientID%>");
        
        dlOldReportTo.value = dlReportTo.value = DataRow[2];

        var dlOldDivision = document.getElementById("<%=dlOldDivision.ClientID%>");
        var dlDivision = document.getElementById("<%=dlDivision.ClientID%>");
        
        dlOldDivision.value = dlDivision.value = DataRow[1];

          var dlOldDesignation = document.getElementById("<%=dlOldDesignation.ClientID%>");
        var dlDesignation = document.getElementById("<%=dlDesignation.ClientID%>");
        
        dlOldDesignation.value = dlDesignation.value = DataRow[0];
    }
}

code behind
VB.NET
<ajaxpro.ajaxmethod()>
Public Function SetEmployeeProperties(ByVal EmployeeCode As String) As System.Data.DataRow
    Dim result As Data.DataRow = Nothing
    Dim dtTable As Data.DataTable = New DataAccessLayer.DataConnection(GB.PropertyManager(Session).ActiveConnectionString).ExecuteToDataSet("select DesigCode,DivCode,ReportTo,DeptCode,LocationID,JobGrade,Rank from employee_mst Where EmpCode = " + EmployeeCode).Tables(0)
    If (dtTable.Rows.Count > 0) Then
        result = dtTable.Rows(0)
    End If
    Return result
End Function
Posted
Updated 22-Aug-24 0:05am
v2
Comments
Richard Deeming 22-Aug-24 5:49am    
You'd need to ask whoever wrote AjaxPro - that's not a built-in part of the framework. The built-in version used either [WebMethod] or [ScriptMethod].

But you have a much bigger problem to fix first: Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation/interpolation to build a SQL query. ALWAYS use a parameterized query.

NB: You may need to rewrite your custom ExecuteToDataSet method to accept parameters, so that it doesn't force you to write vulnerable code.

Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^]
How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^]
Query Parameterization Cheat Sheet | OWASP[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900