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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

asp.net AJAX, how to respond a javascript AJAX call

Posted By:      Posted Date: September 27, 2010    Points: 0   Category :ASP.Net

Dear Friends

I have a problem

condition : server = asp.net FW3.5 .... Client = just and just htmls (no server control /no runat ="server" att)

i open a ajax request from browser and that is ok


1. in case above  a page_load happend on server we all know that, but i cant determine is it asynchorus load or normal load

2. as response of that AJAX call i can't use response.write() cause it will redraw entire page not just a portion

In Litle Details: suppose i there is a <div id = ....> on client page, i just need to send a table, after that javascript will put that under the div.

and response write can't do this cause it send xml for entire page not for just tha table,

So friends Please Help


View Complete Post

More Related Resource Links

How to track Collapse/ Expand event of AJAX Collapsible Panel Extender to call javascript ?



I am working with AJAX Panel Collapsable panel extender.

The Panel which is to be collapsed/Expanded using AJAX panel Extender contains one custom control, containing 3 Radio buttons one of them is set checked through a javascript function when page loads. I have kept the default property of AJAX collapsable panel as Collapsable.

Script for AJAX Collapsible Panel Extender is as follow. 

 <ajax:CollapsiblePanelExtender ID="cpeSOP" runat="Server" CollapseControlID="pnlCollapsable"
   CollapsedSize="0" Collapsed="True" CollapsedImage="~/public/img/arrowRightWhite.gif"
   ExpandControlID="pnlCollapsable" ExpandDirection="Vertical" ExpandedImage="~/public/img/arrowDownWhite.gif"
   ImageControlID="Image1" SuppressPostBack="true" TargetControlID="pnlSearchCriteria">

But problem is that when page loads, collapsible panel gets collapsed but it resets the radio buttons in custom control. i.e. First radio button does not get checked. Script for Collpsable panel is as follow. I want to call some javascript code when the panel is Collapsed or Expanded. Is there any way to track Coll

.ajax() call in javascript functon


i have a jquery .click() function that executes an .ajax() method call

 $(".btn-play").live("click", function () {
                //set globalSortNumber
                globalSortNumber = $(this).parents("[sortnumber]").attr("sortnumber");//.attr("value") ; //change should be some type of input like mediaid //see if its possible to add the sortID to the handle span
//                alert(globalSortNumber);
                //set title
                //set mediaID
                var mediaID = $(this).parents("[mediaid]").attr("mediaid");
//                alert(mediaID);
                //ajax query to get link and excute code to launch music
                    data:"{'mediaId':" + mediaId + ",'userId':" + "0" + "}",
                    contentType:"application/json; charset=utf-8",
                    success:function (msg) {
                        if (msg.d != "") {
                            else {

Using jQuery to directly call ASP.NET AJAX page methods

Here I am looking to explain how to call page methods using jQuery. Using jQuery to directly call ASP.NET AJAX page methods

Ajax Enabled Gridview using JavaScript in ASP.NET

Before explaining the article, I would like to thank all readers who read my article and voted for it. Your appreciation for my article gives me strength to write more good articles. Hope in future I will get your valuable comments and suggestions. Now I won't waste your time and come back to the topic. I have written this article on 'Ajax Enabled Gridview Using JavaScript in ASP.NET'. In this article, I will show you how to make a Gridview using a simple HTML table, JavaScript and XML HTTP for Ajax call without using any ASP.NET control.

Using Code

GridView Javascript Click Row and Ajax

This article shows 2 common tasks with the ASP.NET GridView: Binding a List (generic) of objects as DataSource and on clicking a row, getting the values of the selected row by a javascript function. In the example a List with User-objects is displayed. On clicking a row containing the data of a User-object, the Id of the object is used to get the address of the user by an Ajax-call and display it in a details-field.

ASP.NET Proxy Page - Used for Cross Domain Requests from AJAX and JavaScript

The article ASP.NET Proxy Page - Used for Cross Domain Requests from AJAX and JavaScript was added by Aamir Hasan on Thursday, August 19, 2010.

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn't allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull content

Jquery Ajax Call to Mvc Action tips.


I try to do a ajax call via the jquery api.

The scritp :

$("#sortColumn").click(function(e) {
                var columnName = $(this).attr('name');
                var sidx = columnName;
                var sord = '<%= (string)ViewData["sord"] == "asc" ? "desc" : "asc"%>';
                var page = '<%= ViewData["page"] %>';
                var rows = "5";
                type: "POST",
                url: "/Mailings/GetData2",
                data: {'sidx': sidx ,'sord': sord ,'page': page ,'rows':  rows },
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(response) {
                var jsonObject = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
                error: function(xmlHttpRequest, textStatus, errorThrown) {
                    document.getElementById('infoContentHeader').innerHTML = xmlHttpRequest.responseText;


And the

MVC with Javascript/AJAX scenario



I'm a rookie with Javascript/Ajax and I was hoping someone could provide an code example or advice of the following scenario:

1.  User clicks a button on the view

2.  Display a message "Waiting to be processed".  (Currently using Javascript)

3.  Execute the action method to retrieve some data.  (Call made from the Javascript)

4.  Return the same view.

5.  Open up a new browser window with a URL that was obtained from the action method.

How do I open a new browser window automatically after the action method is complete?  I was previously making the following call (Process.Start(http://www.yahoo.com);) in the action method but I'm running into issues with it.  I'd like to use Javascript/Ajax.


If it helps this the javascript code that is run when the button is clicked:

function runReportMessage() {
    document.getElementById("runReport").innerHTML = "Running the report. Please wait";
    document.getElementById("btnRun2").disabled = "

$.ajax post from asp.net page and __viewstate causing call to fail



Now I know that I won't be sending viewstate and eventvalidation in my ajax calls and that I will only want to send the actual form fields for efficiency purposes but I will need to know the answer to this question, to inform the more junior members of the team and my manager, so if anyone has any answers they are most welcome.

I have a simple form as follows

<form id="form1" runat="server"> 
<p>Field1: <

ajax call to webservice

I am new to jquery and want to make a simple jquery ajax call to webservice. My webservice is running fine but I am unable to get the data through ajax and jquery. My code is <%@ Page Language="C#" AutoEventWireup="true" CodeFile="WS.aspx.cs" Inherits="WS" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"><title></title> <script src="jquery-1.4.2.min.js" type="text/javascript"></script> <script  type="text/javascript"> $(document).ready(function() { $("#btGetDate").click(function() { //$("#dvDate").html("I am here"); $.ajax({ type: "POST", url: "WebService.asmx/GetDateTime", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { $("#dvDate").html(msg); } }); }); }); </script> </head> <body> <form id="form1" runat="server"> <div> <div id="dvDate"></div><input id="btGetDate" type="button" value="Get Date" /> </div> </form> </body>  

Change active tab in Ajax tab container using javascript

I have been using the ajax tab control. I need to change the active tab index of the tab container through javascript. Can please anyone tell me how can i do it Cheers Sohail Sayed

AJAX call is not working on F5 load balancer web farm setup

I have the following web farm setup in production server.Browser --> HTTPS --> Load Balancer --> HTTP --> webserver nodeF5 Load balancer handles off box SSL termination. It implies that SSL resides on F5 load balancer. Problem Statement: Ajax calls do not go through unless "Access data sources across domains" option is enabled in IE security settings. I have the similar setup in staging server except F5 Load balancer. The ASP.Net application makes perfect AJAX calls on both HTTP and HTTPS.However, the staging server web farm use windows NLB and SSL resides on individual web server nodes

Get xhr object in vb.net when error occured in ajax call using JQuery.

Hi Dude,   I have a big problem in Jquery ajax call. I am calling the web service whenever click the update button. I have a separate web service class, in which consist of few methods. When I calling the web service method, I have made the error handling and log the error information in db after that I have to override the "ex" that means error object to XMLHttpRequest. Is it possible to assign the sqlexception to ajax object (xhr) in vb.net? Please help me its much more useful for me.   Thank in advance.

How to access ServerSide control Value in Javascript changed by Ajax

Hello,I have a Textbox whose value is been changed using ServerSide code (AJAX based - Partial postback) and now I want to access that changed value in JavaScript. Please suggest me that how can I access that value.document.getElementByID is displaying old value.Things work fine with full postback but are creating above issue with Partial Postback.Thanks, in Advance....

ASP.NET AJAX and javascript

I have DropDownList "DropDownList1" that have to items 1-displayTextbox1 that display textbox "TextBox1" using javascripts.2- removeTextbox1  that remove textbox "TextBox1" using javascripts.This javascript function is OnSelectedIndexChange. This function call when the DropDownList1 item change using below code on Page_Load void. protected void Page_Load(object sender, EventArgs e) { DropDownList1.Attributes.Add("onChange", "return OnSelectedIndexChange();"); }   The code of OnSelectedIndexChange is :<script type="text/javascript"> function OnSelectedIndexChange() { var iDDL= document.getElementById("DropDownList1"); var iTextBox1= document.getElementById("TextBox1"); var iDDLSelectedValue = iDDL.options[iDDL.selectedIndex].value; if (iDDLSelectedValue == "displayTextbox1") { iTextBox1.style.display = "block"; } else { iTextBox1.style.display = "none"; } } </script>   Complete code : The asp cage is :<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W

Authentication timeout while making AJAX call?

Hi,I tried to take advantage of jQuery AJAX call to enhance user experience but I am facing a tricky problem.When the user does nothing for a period of time, e.g. 30 minutes to reach authentication timeout, making AJAX call becomes the problem. The server side will return login page and display in my target div section. The simplest solution I can think of is to inject a dummy tag in login page, and when detecting such dummy tag then use javascript to redirect to login page. But this means that I have to do that every time I make AJAX call. Is there any more decent way to do that? Regards,Charlie

Dynamic Javascript in Ajax Partial View

I have a partial view which uses Ajax.ActionLink to perform paging.  The AjaxOptions in the link identify the update target (a div on the main view) and some javascript to run OnSuccess (in the partial view).  The javascript must be in the partial view since there is some information in the partial view required to properly wire up the jQuery in the javascript.  This isn't working as expected.  The sample below is the minimum code to duplicate the behavior I am seeing: Controller: private static int count; // // GET: /Home/ public ActionResult Index() { ViewData["Test"] = count++; return View(); } [HttpPost] public ActionResult TestPartial() { ViewData["Test"] = count++; return PartialView(); } View:  <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Index</title> <script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script> <script
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

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