.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Ajax >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Client Request without refresh the page using Ajax. in vb.net

Posted By:kmmuthu       Posted Date: July 23, 2009    Points: 10    Category: Ajax    URL: http://www.dotnetspark.com  
 

Client Request without  refresh the page using Ajax. in vb.net


Your Input form
      txtUser Name-- Text BoX
      btnDetails   --Details Button
 you click  Details button.and load detail address for that customer in the same page  in address  labels...

in javascript...button click

function   loadDetails()
{
var userName =document.getElementById("txtUserNAme").value;

    g_httpRequest = new ActiveXobject("Microsoft.XMLHTTP");
    g_httpRequest.onreadystatechange=ResponseResult;
    g_httpRequest.open('GET', "UserServerPage.aspx?UserName=" + userName, true);
                g_httpRequest.send(null);
}


function ResponseResult ()          //Return result from server side page
{
try
            {
                if (g_httpRequest.readyState==4)
                {
                    var r = g_httpRequest.responseText;
                  docment.getElementID("lblAddress").value=r;
                }
            }
            catch(e)
            {
                ShowScriptError(e,"ResponseResult ()");
            }
}

in server side page you have write this code in page load

dim     userName as string

Dim Con as sqlConnection
dim result as string
din Cmd as SqlCommand
dim sdr as SqlDatareader

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

try

   userName = Request.QueryString("UserName ")

    con =new sqlconnection("connection string.......")

    cmd =new Sqlcommand("Select Address from Customer where customerName ='"+UserName+"',con)

     Rdr = Cmd.ExecuteReader()
     If Rdr.HasRows Then
      While (Rdr.Read)
    {
    result=Rdr.GetValue(Rdr.GetOrdinal("PrdName"))

    }
catch Ex as Exception
throw Ex

End try

  Response.Write(Result)
  Response.End()

end sub

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply

    Read also another Resources from the same Author

Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend