2012-01-30 2 views
0
<AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)> _ 
Public Function HandleSelect(ByVal table As String, ByVal eventSource As String, ByVal filterValue As String, ByVal targetControl As String) As StreetNameResponse 

    Dim tName As TableName 
    Dim filter As String = Nothing 
    Dim sort As String = Nothing 
    Dim textField As String = Nothing 
    Dim valueField As String = Nothing 
    Dim name As String = Nothing 
    Dim onChange As String = Nothing 
    'Assign security filter 
    CheckSecurityFilter() 

    Select Case table.ToLower 
     Case "county" 
      tName = TableName.County 
      If filterValue = "-1" Or filterValue = "" Then 
       If _restrictionLevel = RestrictionLevel.District Then 
        filter = _restrictionFilter 
       End If 
      Else 
       filter = String.Format("maintdisnmbr in ({}0)", filterValue) 
      End If 
      tName = TableName.County 
      sort = "countyname ASC" 
      textField = "countyname" 
      valueField = "countynmbr" 
      name = "selCounty" 
      onChange = "CheckSubmitEnabled();ajaxGetSelect('city','county', this, 'spanCity')" 
     Case "city" 
      If filterValue = "-1" Or filterValue = "" Then 
       'No value selected, set the filter to the default security value 
       If _restrictionLevel = RestrictionLevel.District Or _restrictionLevel = RestrictionLevel.County Then 
        filter = _restrictionFilter 
       End If 
      Else 
       Select Case eventSource.ToLower 
        Case "district" 
         filter = String.Format("maintdisnmbr in ({0})", filterValue) 
        Case "county" 
         filter = String.Format("countynmbr in ({0})", filterValue) 
       End Select 
      End If 

      tName = TableName.MasterCity 
      sort = "sams_cityname ASC" 
      textField = "sams_cityname" 
      valueField = "cityname_value" 
      name = "selCity" 
      onChange = "CheckSubmitEnabled()" 
    End Select 
    Dim selOutput As HtmlSelect = BuildSelect(tName, filter, sort, textField, valueField, name, onChange) 
    Dim outControl As New StreetNameResponse 
    outControl.targetControl = targetControl 
    outControl.outputControl = selOutput 
    MyBase.ProperCaseSelectControl(selOutput) 
    Return outControl 
End Function 

위 코드에서 디버깅 문제가 있습니다. 요점은 HTML에 있는데 세 개의 선택 태그가 있습니다. 지구, 군 및시. 교육구를 선택하면 해당 교육구의 카운티 또는 도시만을 제한하도록 카운티 및시를 갱신해야합니다. 시는 완벽하게 작동하지만 카운티는 그렇지 않습니다. 필자는 위의 코드를 통해 County Case 세그먼트를 실행하는 경우 filter = String.Format ("maintdisnmbr in ({} 0)", filterValue) 만 중지한다는 것을 발견했습니다. 단계별로 단계별로 진행하면 코드가 완료되지 않습니다. 단계별로 단계별로 나가지 않고 앞으로 뛰어 오르면 입력 문자열이 형식화되어 있지 않다는 오류가 발생합니다. 이것은 내 코드가 아니며 Ajax와 작업하지는 못했지만 문제를 해결하는 데 큰 도움이된다면 문제를 해결해야합니다.코드 끝까지 Ajax 호출이 중지됩니다.

+0

이 보인다. 나쁜 코드 원숭이. 쿠키가 없습니다. –

답변

1

이 :

"maintdisnmbr에서 ({} 0)"

이 대신과 같아야합니다

"({0})에 maintdisnmbr"

그러나 인 경우 당신은 SQL 인젝션에 취약 할 수 있습니다. 당신이 좋은 코드를 원한다면, 당신은 제대로 SQL 서버 목록을 통과에 기사의이 시리즈를 읽을 수 있습니다 : 그것은 SQL 주입 공격에 취약 할 것 같은

http://www.sommarskog.se/arrays-in-sql.html

+0

지금 당장은 코드를 작동 시키려고 노력하고 있습니다 ... 우리는 팀을 떠났습니다. 그래서이 프로젝트의 모든 사람들은 코드를 작성하지 않았습니다. 우리는 나중에 굴절시킬 것입니다. 간과 한 간단한 실수를 지적 해 주셔서 감사합니다. – cjohnson2136

관련 문제