Saturday, March 31, 2012

Jquery AutoFill in asp.net










<%@ WebHandler Language="VB" Class="Search_VB" %>

Imports System
Imports System.Web
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Text
Imports System.Web.SessionState

Public Class Search_VB : Implements IHttpHandler
Implements IRequiresSessionState

Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

Dim val As String = context.Request.QueryString("id")
Dim name As String
Dim id As String

If val = "1" Then

Dim part As String = Convert.ToString(HttpContext.Current.Session("part_id"))

Dim prefixText As String = context.Request.QueryString("q")
Dim conn As SqlConnection = New SqlConnection
conn.ConnectionString = ConfigurationManager _
.ConnectionStrings("SurgereConnection").ConnectionString
Dim stbuilder As New StringBuilder()
Dim exst_partid As Boolean = False
If val = "1" Then
If HttpContext.Current.Session("part_id") <> "" Then
exst_partid = True
stbuilder.Clear()
stbuilder.Append("Select Supplier_id,Supplier_name,upper(isnull(Supplier_code,'')) as Supplier_code from supplier where ")
stbuilder.Append("(Supplier_name +'-'+ upper(isnull(Supplier_code,'')) ) LIKE '" & prefixText & "%'")
stbuilder.Append(" and Supplier_id in (select Supplier_id from part_supplier_join where is_active_yn=1 and part_id=")
stbuilder.Append(Convert.ToInt64(Convert.ToString(HttpContext.Current.Session("part_id"))) & ")")
stbuilder.Append(" and Client_id=" & Convert.ToInt64(Convert.ToString(HttpContext.Current.Session("clientid"))))
Else
exst_partid = False
End If

End If
If val = "1" Then
If exst_partid = False Then
context.Response.Write("Choose Part..")
Else
Dim cmd As SqlCommand = New SqlCommand
cmd.CommandText = stbuilder.ToString()
cmd.Connection = conn
Dim sb As StringBuilder = New StringBuilder
conn.Open()
Dim sdr As SqlDataReader = cmd.ExecuteReader
While sdr.Read
name = sdr("Supplier_name").ToString & "-" & sdr("Supplier_code").ToString
id = sdr("Supplier_id").ToString
sb.Append(String.Format("{0}|{1}|{2}", name, id, Environment.NewLine))

'sb.Append(sdr("Supplier_name").ToString & "-" & sdr("Supplier_code").ToString) _
' .Append(Environment.NewLine)
End While
conn.Close()

If sb.ToString() <> "" Then
context.Response.Write(sb.ToString)
Else
context.Response.Write("Not available..")
End If
End If

End If



End If

End Sub

Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property

End Class

No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...