How to pass vals to webservice funciton RRS feed

  • Question

  • User-582711651 posted


    I want to pass two variables from aspx page to a function in webservice, then need to get return string, if string having content show (alert) else not required to show, please refer my code here, 

    This is my Aspx code, when the client change the date then, I want to pass parameters viz., Lbl_empid, txt_ResignDate to the following function (ref my below-mentioned webservice code)

    <asp:TextBox ID="txt_ResignDate" runat="server" CssClass="normalText2" MaxLength="10" Width="70px" ></asp:TextBox>
    <asp:Label ID="Lbl_empid" runat="server" ForeColor="Gray"></asp:Label>

    AutoComplete.asmx code
    : <%@ WebService Language="VB" CodeBehind="~/App_Code/MyEngine.vb" Class="Vali_HoliDates" %>


    <WebMethod()> Public Function Get_ValiHoliDays(ByVal ip_empid As Integer,_
    ByVal ip_date As Date, ByVal op_val As String) As String()

    Dim sCon As New SqlConnection(DBConnectionString) Dim param As SqlParameter Dim sCmd As New SqlCommand(selectSQL, sCon) Try sCon.Open() sCmd.CommandType = CommandType.StoredProcedure sCmd.CommandText = "HRMSP_Validate_OffHoliday_Dates" sCmd.Parameters.Clear() sCmd.Parameters.Add(New SqlParameter("@i_SP_AttribuId", SqlDbType.Int)).Value = 1 sCmd.Parameters.Add(New SqlParameter("@i_EmployeeID", SqlDbType.Int)).Value = ip_empid sCmd.Parameters.Add(New SqlParameter("@i_ValiDate", SqlDbType.Date)).Value = ip_date param = New SqlParameter("@o_ErrorStatus", SqlDbType.Int) With { .Direction = ParameterDirection.Output } sCmd.Parameters.Add(param) adapter.Fill(dsDataset) If sCmd.Parameters("@o_ErrorStatus").Value = 1 Then op_val = (dsDataset.Tables(0).Rows(0).Item(0).ToString) ElseIf sCmd.Parameters("@o_ErrorStatus").Value = 2 Then op_val = "" End If Finally sCon.Close() End Try End Function

    Thanks in advance
    Wednesday, February 26, 2020 4:45 AM

All replies