+ Reply to Thread
Results 1 to 7 of 7

Thread: Ajax vb

  1. #1

    Default Ajax vb

    This tutorial will show you how to use AJAX with VB.NET to change any part of your web page, without reloading the page (click here for an example). By using the XMLHttpRequest object and split values produced from VB.NET at lightning fast response times, you can change many parts of your website instantly. Simply download the completed working project and modify the code to work on your website to design various AJAX projects with VB.NET like an advanced search, chatrooms, IM’s or whatever. You can go through the 3 documents which include all the instructions you need, or read on…

    Index.html
    The document / front end that the user will see

    1. Include the AJAX code / JavaScript needed to generate the different html parts

    Code:
    <script src="ajax.js" type="text/javascript"></script>
    2. You can call the ”fncResults” function in the <body> tag’s “onload” event to initiate the AJAX result, or you can use various other controls like the textbox’s “onKeyUp”, or a dropdown list’s “onChange” event. Use a value in the brackets to determine what control was last changed to initiate the AJAX request.

    Code:
    <body onLoad="fncResults(0);">
    OR
    <select onChange="fncResults(1);">
    OR
    <input type="text" onKeyUp="fncResults(2);">
    3. Add span tags with IDs around AJAX loading gifs which will notify the user when an AJAX request is being processed.

    Code:
    <span id="spnLoaderSquare"><img src="ajax-loader.gif" /></span>
    <span id="spnLoaderType"><img src="ajax-loader.gif" /></span>
    <span id="spnLoaderPut"><img src="ajax-loader.gif" /></span>
    4. Place span tags and assign an ID to each which will be used to apply dynamic html values in from the ajax.js document using the “innerHTML” property

    Code:
                <tr>
                  <td height="25%">r1</td>
                  <td><span id="spn_R1_C1"></span></td>
                  <td><span id="spn_R1_C2"></span></td>
                  <td><span id="spn_R1_C3"></span></td>
                </tr>
    Ajax.js
    The AJAX / JavaScript code needed to retrieve the values from ajax.aspx, and display them in index.html

    Note: Simply change the values where it is marked: //CHANGE to match your content

    1. This snippet will display or remove the AJAX loading gif when necessary to notify the user that the AJAX info is loading. Change the values ('spnLoaderPut', 'spnLoaderType', 'spnLoaderSquare') to the span tag IDs on your HTML page where you like the loading gif/s to display.

    Code:
    	
    fncVisibility('spnLoaderPut', 'inline');
    fncVisibility('spnLoaderType', 'inline');
    fncVisibility('spnLoaderSquare', 'inline');
    Code:
    	
    fncVisibility('spnLoaderPut', ‘none’);
    fncVisibility('spnLoaderType', ‘none’);
    fncVisibility('spnLoaderSquare', ‘none’);
    2. The following code specifies the path to the VB.NET document where the dynamic values can be retrieved from, and also allow you to pass values using a query string.

    Code:
    	var strUrl = "ajax.aspx";
    	strUrl = strUrl + "?put=" + document.getElementById("ddlPut").options[document.getElementById("ddlPut").selectedIndex].value;
    	strUrl = strUrl + "&typing=" + document.getElementById("txtType").value;
    	strUrl = strUrl + "&square=" + document.getElementById("ddlSquare").options[document.getElementById("ddlSquare").selectedIndex].value;
    	strUrl = strUrl + "&lastchanged=" + strObject;
    3. After retrieving the string produced from the VB.NET document, split the values by assigning the string to an array, then apply each value individually to the different sections of your HTML document. The string is split by the value “[CWAsplit]” in the VB.NET document

    Code:
    		var strCWAsplit = objXmlHttp.responseText.split("[CWAsplit]") 
                    if(strCWAsplit[0]){document.getElementById("spn_R1_C1").innerHTML=strCWAsplit[0];}
    		if(strCWAsplit[1]){document.getElementById("spn_R1_C2").innerHTML=strCWAsplit[1];}
    		if(strCWAsplit[2]){document.getElementById("spn_R1_C3").innerHTML=strCWAsplit[2];}
    		if(strCWAsplit[3]){document.getElementById("spn_R2_C1").innerHTML=strCWAsplit[3];}
    		if(strCWAsplit[4]){document.getElementById("spn_R2_C2").innerHTML=strCWAsplit[4];}
    		if(strCWAsplit[5]){document.getElementById("spn_R2_C3").innerHTML=strCWAsplit[5];}
    		if(strCWAsplit[6]){document.getElementById("spn_R3_C1").innerHTML=strCWAsplit[6];}
    		if(strCWAsplit[7]){document.getElementById("spn_R3_C2").innerHTML=strCWAsplit[7];}
    		if(strCWAsplit[8]){document.getElementById("spn_R3_C3").innerHTML=strCWAsplit[8];}
    		if(strCWAsplit[9]){document.getElementById("spnResult").innerHTML=strCWAsplit[9];}
    Ajax.aspx
    The code behind that will produce the dynamic split values to be retrieved in ajax.js

    Basically what this document does is to print one string value that has split anchor points ("[CWAsplit]") which will be split into any amount of values to apply to various parts of the index.html document. See the attached file for more info
    Attached Files
    CWA - CoolWebAwards.com

  2. #2

    Default

    AJAX, refer as Asynchronous JavaScript And XML, is not a technology but rather a alignment of technologies. AJAX uses a advice technology about SOAP and XML to forward and accept an asynchronous acknowledgment to the server, and again leverages presentation technologies JavaScript, DOM, HTML, and CSS to action the response. Applications application AJAX are accepted today, because a lot of browsers abutment the all-important technology.

  3. #3

    Default

    Ajax VB 's Tutorial is really very useful and Informative for us. Thanks for Providing this Ajax VB 's Tutorial to us. AJAX is very useful in a Web Based Area. AJAX means Asynchronous Javascript and XML.

  4. #4

    Default

    Another method for using AJAX.

    From toolbox drag & drop the script manager, Update panel and timer controls. Within this update panel, insert the controls to be updated. Set the timer interval. Write code in timer-tick function.

    Cegonsoft OJT
    Last edited by Michael Caine; 07-15-2011 at 02:06 PM.

  5. #5

    Default

    I was wondering if any one knews any good tutorials on AJAX using VB?




    Campus Recruitment Company
    Job Placement Agency

  6. #6

    Default

    Lot of developers are working with Visual Basic .NET I put the a new example online written in VB.NET. The example will be the same as the C# version. I will update both projects in the future to help VB.NET developers.


    Top MBA Colleges in India
    Business School Ranking

  7. #7

    Default

    var result = $.ajax({
    type: "POST",
    url: "online-order-bulb.aspx/AddProductToCart",
    data: '{ pID: "1833", qty: $(this).val(), lblType: "1" }',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(msg) {
    alert("success");
    },
    failure: function(msg) {
    alert(msg);
    },
    error: function(xhr, err) {
    alert(err);
    }
    });


    Mumbai Schools Ranking
    Mumbai Schools List

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts