We help IT Professionals succeed at work.
Get Started

javascript/vb.net - Issue with Web Handler(.ashx)

813 Views
Last Modified: 2012-05-12
Having issue with the code. The goal is that when a value is read into a field, take that via .JS/.AShx to the db and back.  If the value is a red_shoe, then red.wav file plays...if the value is a green_shoe then green.wav file plays...

it runs fine up thru the vb.net and javascript but errors out when it tries to call the .ashx page...
//// javascript code....



function whichShoe() {
 
    shoe_number = ReceivedDate = document.getElementById(var_txtShoe_id).innerHTML;

    // PASS THE VALUE OF THE SHOE INTO THE .ASHX TO RUN AGAINST THE WEB PAGE TO SEE WHAT VALUE SHOULD RETURN...
    var xmld = load_xml("../Handler/shoe.ashx?Task=GetWhichShoe=" + shoe_number)

    if (xmld != null) {
        // Validation Completed
        // var procRetVal = getNodeValue(xmld, "retVal")

        if (xmld = 2) {
            red_shoe()
        }
        else {
            green_shoe()
        }

    }
    else {
        alert(" Please Contact The System Administration For Support.")
        return;
    }
    return;



}


'''' web handler... .ashx


Public Class ShoeHandler : Implements IHttpHandler
    
    Dim log As ILog = LogManager.GetLogger(GetType(ShoeHandler))
    
    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        ''' ROUTE TO THE CORRECT METHOD

	   if	...code....

	   ElseIf context.Request.QueryString("Task") = "GetWhichshoe" Then
            GetWhichShoe(context, context.Request.QueryString("shoe_Number"))
           End If



    end sub

   Private Sub GetWhichshoe(ByVal context As HttpContext, ByVal var_shoeNumber As String)
        
       
        Dim var_which_shoe As String
        var_which_shoe = ""
        Dim filename As String
        filename = ""
        
        var_shoenumber = LTrim(RTrim(var_shoenumber))


        Try

            Dim dataReader As SqlDataReader
            Dim x As Integer = 0
            Dim sqlConnection As String


            Using sqlConn As New SqlConnection
                sqlConnection = "Data Source=TestshoeDB;Initial Catalog=shoes_finnish;Persist Security Info=True;User ID=ee;Password=ee"
                sqlConn.ConnectionString = sqlConnection
              

                Dim SQLstring As String = "select distinct (" & var_shoenumber & ") from shoes_Finnish_old " & _
                " where ProductID in (select ProductID from Products where shoe_leather = 'rr2111')"

                sqlConn.Open()
                Using command As New SqlCommand(SQLstring, sqlConn)
                    dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
                    If dataReader.HasRows Then
                        Do While dataReader.Read()
                            HttpContext.Current.Session("shoenumber_value") = dataReader("shoe_type_finnish_old").ToString()
                        Loop

                    End If
                    dataReader.Close()
                    sqlConn.Close()
                End Using
            End Using

        Catch ex As Exception
        Finally
        End Try

   



        ' ================================================================================
        ' _+_+_+_+_+_+_+_+_+_+_+_+
        ' 
        ' find the right wav filefor the type of shoe...


        If HttpContext.Current.Session("shoenumber_value") = 2 Then            
            var_which_shoe = 2

        End If

        If HttpContext.Current.Session("shoenumber_value") <> 2 Then
        
            var_which_shoe = 1

        End If
       
        
        context.Response.Clear()
        context.Response.ContentType = "text/xml"
        context.Response.Write(var_which_shoe)
      
    End Sub

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
This problem has been solved!
Unlock 1 Answer and 15 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE