Contact   •   Products   •   Search

Rick Strahl's Web Log

Wind, waves, code and everything in between...
ASP.NET • C# • HTML5 • JavaScript • AngularJs

jQuery and ASP.NET Article Part 2 Posted


I’ve posted part two in the (now) three part series of articles about jQuery with ASP.NET today. You can read the article here:

jQuery with ASP.NET (Part 2: Making Ajax Callbacks to the Server)

Part 2 of this article series deals entirely with various ways of interaction between jQuery and ASP.NET server side code for making AJAX callbacks.  If you have any questions or comments regarding this article please leave them below.

If you missed Part 1 – it is an introduction to jQuery and focuses primarily on the client side features of jQuery.

An Introduction to jQuery (Part1: The Client Side)

Although this article uses ASP.NET for the sample discussed the content in Part 1 is really server platform agnostic.

Part 2: Focus on Ajax and Server Callbacks

The new article first introduces the basic features available in jQuery and then proceeds to demonstrate a number of different ways to call ASP.NET code. A wide variety of topics are covered from basic .load() calls to separate URLs, to same Page callbacks with Html and JSON data. The bulk of the article focuses on interacting with WCF and ASMX services for raw AJAX callbacks that treat ASP.NET primarily as a data backend for a client application. There’s also some discussion of using client side templating for rendering and maintaining HTML in one place and several extensive sample applications are provided to demonstrate the concepts.

The sample project also includes a host of utilities and what is basically the West Wind Ajax Toolkit Version 2.0. The jQueryControls project contains a number of server controls that simplify a number of client scenarios and also includes a few useful utilities like the ClientScriptProxy, ScriptVariables and ScriptContainer components. The tools have all been updated to work with jQuery on the client.

The article is fairly long (yeah, yeah what else is new?) , mainly due to a fair number of code listings and detailed discussion of some of the examples. As I was writing this thing I was trying to incorporate a number of the questions and comments I’ve heard in the last few months. Hopefully some of you will find this useful.

I thought I was going to do only two parts in this series, but since I ran a bit long on the AJAX portions I decided to leave the server side integration topic (server control creation, wrapping client functionality etc.) for another article. Not only would this article have gotten too long but it would also have blurred the focus at the end. Eeek, two down one more to go…

Make Donation
Posted in jQuery  ASP.NET  AJAX  WCF  


Feedback for this Post

 
# jQuery and ASP.NET Article Posted
by DotNetKicks.com December 03, 2008 @ 2:32am
You've been kicked (a good thing) - Trackback from DotNetKicks.com
# jQuery and ASP.NET Article Part 2 Posted - Rick Strahl's Web Log
by Web Development Community December 03, 2008 @ 6:12am
You are voted (great) - Trackback from Web Development Community
# re: jQuery and ASP.NET Article Part 2 Posted
by Steve from Pleasant Hill December 04, 2008 @ 6:11am
Great stuff. This now allows me to throw away notes I've scribbled while experimenting with this technology.

The first time I used jQuery to call a service and plop stuff into a DIV tag was rather exhilarating, but I'm not quite sure why...
# re: jQuery and ASP.NET Article Part 2 Posted
by Lee Baker December 04, 2008 @ 2:33pm
Thanks Rick,

This is a great article. Well written and really opened my eyes about what is possible using jQuery.

Lee
# re: jQuery and ASP.NET Article Part 2 Posted
by Tim December 05, 2008 @ 7:53am
Hi Rick

Why not use pagemethods if you want to post back to the same page.
This gives you a much cleaner way to specify your callback method.

Instead of figuring it out in the page load, you directly call the pagemethod...

Just a thought

Tim
# re: jQuery and ASP.NET Article Part 2 Posted
by Rick Strahl December 05, 2008 @ 11:53am
@Tim - PageMethods are just another way that is effectively a Web Service call. Since PageMethods are static you have no access to the page and its logic, so these methods have to be self contained like the service callbacks I mentioned in the article.

There's a place for doing manual routing if you need access to other content in the page or rely on controls that are defined on the page. For example, the list view rendering example wouldn't work from a Page method because the listview is defined on the page itself and you don't have access to that from Pagemethods.

That doesn't make it a bad choice - it's just closer to the service implementation which I would always recommend instead of page methods for purposes of separation of concerns.
# re: jQuery and ASP.NET Article Part 2 Posted
by indy December 05, 2008 @ 4:41pm
Rick,

This is a fantastic post! It came at a time when I was working with jQuery and ASP.NET MVC and wanted a simple control to query a JSON service. Thanks very much! By the way, the stock server burps as it can't find the database! Will you post the database MDF or the SQL script create the database?

Cheers,
indy
# re: jQuery and ASP.NET Article Part 2 Posted
by eKnacks December 06, 2008 @ 3:23am
You've been knacked. Keep up the good work.
# re: jQuery and ASP.NET Article Part 2 Posted
by satish December 06, 2008 @ 8:19am
fantastic article.. waiting for the third part.. why cant u try to put this as a book (just a small suggestion)..i am following all your articles on jquery from the first... just mind blowing .... and i am suggesting the approach what you have shown here to my company buddies...keep up the good work


cheers,
satish
# re: jQuery and ASP.NET Article Part 2 Posted
by satish December 06, 2008 @ 9:27am
as i told you i am working on the template .. i am able to solve the first issue.. now the second is

$.getJSON("Default.aspx?Callback=getRiskbyId", { RiskId: Riskid }, function(result) {
// Retrieve the Item template
var template = $("#grdRiskValues").html();
// Parse the template and merge stock data into it


var html = parseTemplate(template, result);

alert(html);
});

i am getting result not defined error from the parse template method.. can i know why is that and how to solve it
# re: jQuery and ASP.NET Article Part 2 Posted
by Rick Strahl December 06, 2008 @ 12:30pm
@Indy - the database is in the APP_DATA folder. The default sample is set up for file based SQL Express database, but you may have to attach the database, set permissions and then change the connection string accordingly.

@satish - you need to step through your code and see what is actually returned in result. The template should not reference result only its properties.
# re: jQuery and ASP.NET Article Part 2 Posted
by satish December 06, 2008 @ 10:49pm
the problem occurs only if put the for construct in the template.. but somehow i tried to make it...thanks for the reply... keep the good work
# re: jQuery and ASP.NET Article Part 2 Posted
by Jakub December 07, 2008 @ 3:31am
Hi Rick,
thank you for an amazing article about using jQuery with ASP.Net. You really saved me a ton of time.
# re: jQuery and ASP.NET Article Part 2 Posted
by Ben Amada December 07, 2008 @ 1:03pm
Wow, long article, but very thorough. In Listing 5 in the ServiceProxy.invoke() function, when the top level object node is being stripped off, if there are 2 items returned from the server, is the callback() function in the FOR loop called two times -- once for each item? The callback function in this case is written using $.each() to iterate over the items in the quotes array. It seems like the callback() function could just as easily be called once with multiple items passed in for the quotes parameter. Just curious, thanks!
# re: jQuery and ASP.NET Article Part 2 Posted
by Ben Amada December 07, 2008 @ 1:21pm
I think I may have answered my own question. With the break; statement in the FOR loop, I guess the FOR loop only runs once and the first property, passed to the callback() function, is the "collection" of items returned from the server. So only one call to the callback function is made.
# re: jQuery and ASP.NET Article Part 2 Posted
by Rick Strahl December 07, 2008 @ 1:26pm
@Ben - I'm not sure I understand your question. Each service call is going to return exactly one result value and that value is parsed out. If you make multiple calls the callback handler is called multiple times, once for each call you made.

The each loop only aims to find the first property by looping over it and then exiting. It's just to return d.firstProperty when callback is called. It's not looping over all properties - in fact there should only ever be one so technically the break isn't necessary, but this is obviously confusing and the break is another reminder.
# re: jQuery and ASP.NET Article Part 2 Posted
by Ben Amada December 07, 2008 @ 1:38pm
Thanks for the explanation Rick. So if there is only one property, I guess the FOR loop with the break statement is equivalent to just result[0].
# re: jQuery and ASP.NET Article Part 2 Posted
by Ben Amada December 07, 2008 @ 4:35pm
Oops, I guess result[0] won't do it. result.d works, but I can see the advantage of the For loop since it avoids having to hard code the letter 'd'.
# re: jQuery and ASP.NET Article Part 2 Posted
by Rick Strahl December 07, 2008 @ 11:38pm
@Ben - you shouldn't hardcode the d because if you end up using ASMX in .NET 2.0 it uses some other identifier for the wrapper object. The parsing is generic and the only way that I could think of getting the identifier of the first property.
# re: jQuery and ASP.NET Article Part 2 Posted
by John Welborn December 08, 2008 @ 9:14pm
You've got a typo in the article title. Says something like ajax callbckas.
# re: jQuery and ASP.NET Article Part 2 Posted
by bz December 11, 2008 @ 2:35pm
Great work Rick!

One thing...in the _readme.htm, it says WcfAjax is a WAP project but I don't see it. I only see WcfAjaxBusiness. Is that a typo? I am able to run with cassini, but when I try using virtual directory I get "Callback Error: undefined"

I am new with WCF, so I may be missing something here...
# re: jQuery and ASP.NET Article Part 2 Posted
by Rick Strahl December 11, 2008 @ 3:53pm
@bz - I removed the WcfAjax project and merged the relevant examples into the main jQueryWeb project.

As to virtual - make sure the virtual is properly configured. You should load the .svc file in the browser to see if it works and follow instructions if it doesn't. Make sure you only have 1 kind of authentication (ie. Anonymous OR Windows but not both) as WCF only supports a single auth mechanism.
# re: jQuery and ASP.NET Article Part 2 Posted
by tw December 12, 2008 @ 3:00pm
Rick

Thanks for the great examples.

What if I need to pass a complex JSON stock object to my WCF service similar to Listing 5?
JSON Example: {"stocks":[{"symbol":"msft","investorinfo":{"sharesowned":"500","datepurchased":"12/01/2008","price":{"purchasedprice":"20.00","commision":"19.95"}}},{"symbol":"goog","investorinfo":{"sharesowned":"100","datepurchased":"12/01/2008","price":{"purchasedprice":"300.00","commision":"19.95"}}},{"symbol":"aapl","investorinfo":{"sharesowned":"50","datepurchased":"12/01/2008","price":{"purchasedprice":"100.00","commision":"19.95"}}},{"symbol":"intc","investorinfo":{"sharesowned":"1000","datepurchased":"12/01/2008","price":{"purchasedprice":"15.00","commision":"19.95"}}}]}

How would I then configure my WCF method? Is there anything special to do to the $.ajax call?
# re: jQuery and ASP.NET Article Part 2 Posted
by Rick Strahl December 12, 2008 @ 3:20pm
@tw - as long as your method signature on the server has the appropriate type that matches the Javascript object structure that you're sending it will serialize and just work.

Ideally the way you want to do this is use the server to give you an existing object - either do a load or new operation. That way you have the server serialize you a C# object marshalled to the client. You can then re-populate that object and send that back to the server which will guarantee that the object can be passed back.

WCF's deserialization will deal with missing properties.

Note though you do need a full type description - you can't take object as a parameter and accept a generic input value - it has to be a specific type.
# re: jQuery and ASP.NET Article Part 2 Posted
by tw December 15, 2008 @ 8:45am
Tried creating an object on the server and retrieving and then updating the values as you suggested. This is my OperationContract
[OperationContract]
[WebGet(RequestFormat = WebMessageFormat.Json)]
public void stocks(List<Stock> stocks)
{
// Do Something
}

However stock is null.

Any suggestions or good examples?
# re: jQuery and ASP.NET Article Part 2 Posted
by tw December 15, 2008 @ 8:49am
Tried creating an object on the server and retrieving and then updating the values as you suggested. This is my OperationContract
[OperationContract]
[WebGet(RequestFormat = WebMessageFormat.Json)]
public void stocks(List<Stock> stocks)
{
// Do Something
}

However stock is null.

Any suggestions or good examples?
# re: jQuery and ASP.NET Article Part 2 Posted
by Rick Strahl December 15, 2008 @ 11:59am
@tw - What are you passing from the client? You need to pass an array of stocks back that looks just like the array going down.
# re: jQuery and ASP.NET Article Part 2 Posted
by tw December 15, 2008 @ 12:36pm
I was trying to pass more complex json

{"stocks":[{"symbol":"msft","investorinfo":{"sharesowned":"500","datepurchased":"12/01/2008","price":{"purchasedprice":"20.00","commision":"19.95"}}},{"symbol":"goog","investorinfo":{"sharesowned":"100","datepurchased":"12/01/2008","price":{"purchasedprice":"300.00","commision":"19.95"}}},{"symbol":"aapl","investorinfo":{"sharesowned":"50","datepurchased":"12/01/2008","price":{"purchasedprice":"100.00","commision":"19.95"}}},{"symbol":"intc","investorinfo":{"sharesowned":"1000","datepurchased":"12/01/2008","price":{"purchasedprice":"15.00","commision":"19.95"}}}]}
# re: jQuery and ASP.NET Article Part 2 Posted
by Rick Strahl December 15, 2008 @ 1:56pm
This should work as long as the JSON signature matches the input object structure AND that all objects are marked for serialization on the server (ie. DataContract/DataMember attributes)...

As I said - the easiest is to look at the serialized object and mimic that structure to pass back to the server.

FWIW, I think it's really bad practice to send back this much data to the server. If you're building apps like this it's often recommended to updates in small chunks - ie. update each stock/portfolio instance individually rather than taking the 'DataSet' approach of modifying a whole set and sending the whole thing back.
# re: jQuery and ASP.NET Article Part 2 Posted
by Vladimir Kelman December 17, 2008 @ 5:47am
@Rick,
You are talking about load function and saying that its format is
$(sel).load(url,callback)
jQuery documentation at http://docs.jquery.com/Ajax/load#urldatacallback says that a format is
load( url, [data], [callback] )
where "data" stands for "Key/value pairs that will be sent to the server".

If I'm not mistaken, your following LDK Stock example

function showStockQuote() {
$("#divResult").load("StockDisplay.aspx", { symbol: $("#txtSymbol" ).val() });
}

follows "load( url, data)" format. "data" is supplied, while "callback" is not. This mistake makes it hard to understand your explanation.
I would tell that a load format is
$(sel).load(url,[data],[callback])
and that in your LDK Stock example "{ symbol: $("#txtSymbol" ).val() }" is "data" parameter.

Thanks.
# re: jQuery and ASP.NET Article Part 2 Posted
by Marc B December 17, 2008 @ 11:20am
@Rick,

"FWIW, I think it's really bad practice to send back this much data to the server. If you're building apps like this it's often recommended to updates in small chunks - ie. update each stock/portfolio instance individually rather than taking the 'DataSet' approach of modifying a whole set and sending the whole thing back."

Are you referring to tw's post (12/15 at 12:36pm)? So, when passing back an array of data like the stock symbols, would you recommend doing a javascript loop on the client side and sending each symbol's data to the server per loop?

for (var i = 0; i < myStocks.length; i++)
{
(ajax call sending each stock symbol's data to server here)
};

thanks
# re: jQuery and ASP.NET Article Part 2 Posted
by Rick Strahl December 17, 2008 @ 11:38am
@Marc - it depends on the data you're sending. Arrays and arrays of objects should work as long as the type signature on the server matches.

The point is to not hold stale information on the client, but update the server in small/atomic and hopefully logical chunks.
# re: jQuery and ASP.NET Article Part 2 Posted
by Rick Strahl December 17, 2008 @ 11:45am
@Vladimir - the data parameter is optional, if not provided the callback can be the second parameter. It works either way.
# re: jQuery and ASP.NET Article Part 2 Posted
by Chris December 23, 2008 @ 12:16pm
Great articles about jQuery. Well written. I am wondering if you could enlighten me with regards to a non-AJAX page. What about a regular ASP.NET "postbacks"? I'm experimenting with jQuery, and have found that the jQuery works great on initial Page_Load(), but if there's a postback, all functionality ceases. Any ideas? Sorry if this exceeds the scope of this blog.

Cheers,
Chris
# re: jQuery and ASP.NET Article Part 2 Posted
by Rick Strahl December 23, 2008 @ 12:20pm
@Chris - there's no reason why things should work any different after a postback. Check for errors in your page using Firebug.
# re: jQuery and ASP.NET Article Part 2 Posted
by Marc December 30, 2008 @ 5:54pm
When using the $.ajax() or $.load() functions to load in a .aspx page, it bombs when certain .net controls are placed on it. I have a page that has a few label controls and a repeater and it loads fine with those. But once I add something like a GridView or a TextBox control, it errors. Any ideas?

thanks
# re: jQuery and ASP.NET Article Part 2 Posted
by Mike January 05, 2009 @ 5:45am
The article rocks and I very much appreciate your time on this. Your methods of explanation are outstanding, short and to the point.

I must say I was quite disappointed to get the code and find I need Sql 2008 to use it. I will still learn from it but not near as easily. It would be nice in the future to try and keep sample code usable by the majority and not littered with other new technologies.
# re: SQL Server 2005 Support
by Rick Strahl January 05, 2009 @ 4:03pm
@Mike - I've added a SQL Packager file (wcfAjax.exe) for the database into the APP_DATA directory. If somebody can try this out and see if this works for getting a workable SQL 2005 database, please leave some feedback here. I currently don't have SQL 2005 installed as I'm travelling, so I have no easy way of testing this...
# re: jQuery and ASP.NET Article Part 2 Posted
by k03123 January 05, 2009 @ 11:39pm
hi rick,

thanks for the great article and accompanying sample projects. i am learning a lot from this.

i think you have mentioned in one of your blog that JSON.net has option to configure settings one being handling recursion loop. wouldn't it be great to have it in your WestwindJsonSerializer as well?

i was playing with it and ran into StackOverflow exception. it was coz i have two objects that has reference to each other.

appreciate your contribution to the community and keep up the good work!


cheers
# re: jQuery and ASP.NET Article Part 2 Posted
by Rick Strahl January 06, 2009 @ 3:29am
@k03123 - yes I know about that problem and I actually just last night set out to fix the recursive reference issue. Recursive references now are set to null if the object in the current branch have already been serialized higher up in the hierarchy.

I haven't updated this yet, but it should show up in the repository for the jQueryControls in a bit.
# Sql Packager File
by Mike January 06, 2009 @ 5:37am
Rick,

Wow, your on top of things. It seems the demo code ZIP hasn't changed, is there somewhere else to look for the wcfAjax.exe file that I am not aware of.
# re: jQuery and ASP.NET Article Part 2 Posted
by Rick Strahl January 06, 2009 @ 6:42am
@Mike - It's in the zip file in jqueryweb\app_data\wcfAjax.exe
# re: jQuery and ASP.NET Article Part 2 Posted
by Mike January 07, 2009 @ 4:59am
Rick,
It is not in the "http://www.west-wind.com/files/conferences/jQuery.zip" file or I am somehow doing something stupid?
# re: jQuery and ASP.NET Article Part 2 Posted
by Amin Sayed January 13, 2009 @ 10:59pm
Hi Rick,
Thanks for such wonderful articles.
I'm stuck up with a problem. I need to fill an empty DropDown List with the values from Database( thereby calling ASP.NET Page methods through jQuery) when user clicks on it. Currently $("#DropDown").click() is being successfully called, but when I'm using $.ajax method inside this function to call ASP.NET Page methods it doesn't work. Please provide your useful inputs for this.
Thanks & Regards,
Amin Sayed.
# re: jQuery and ASP.NET Article Part 2 Posted
by Dan February 21, 2009 @ 8:35am
Hello Rick. As always, this article is great. I've read parts one and two a dozen times. Very helpful. I've created a project that combines both the C# and Java versions of YUICompressor where the user can select which version to use. I've noticed that when I compress jQuery, the header (version, credits, copyright) remain after compression; while with ww.jquery.js, et al. the header is removed. I've determined that if you comment your header in the following format, the header will remain once the compression is complete. Manually deleting the header is obviously not a barrier; however, your code still deserves to have the header intact post compression. I think the trick is the '!' on the first line of comments. Hope that you find this useful, and thanks for all you support to the community. Peace... -Dan
/*!
* ww.jQuery.js  
* West Wind jQuery plug-ins and utilities
*
* Copyright (c) 2008 Rick Strahl, West Wind Technologies 
* www.west-wind.com
*
* Licensed under MIT License
* http://en.wikipedia.org/wiki/MIT_License
*
* Version 0.90.672 - 12/01/08
*/
# re: jQuery and ASP.NET Article Part 2 Posted
by Tony March 06, 2009 @ 9:40am
Hi,

I have validation.js and AJAX UpdatePanel to download a file on the server. As soon as I upload the file the page is broken- doc.ready () is not firing again I think and my validation rules error. How do I fix this?
# re: jQuery and ASP.NET Article Part 2 Posted
by jkong March 06, 2009 @ 11:25am
Rick,
You are one of my favorite bloggers.
Thank you for your hard work.
Amazing.
# re: jQuery and ASP.NET Article Part 2 Posted
by Danny117 March 17, 2009 @ 7:39pm
I come across your blog often when I'm looking for something cool.
Thanks
Dan
# re: jQuery and ASP.NET Article Part 2 Posted
by SSL March 18, 2009 @ 11:38am
Rick,

You have some great articles which I enjoy reading about. I wonder if youcn help me.

I have 3 HTML checkboxes which are programmed via jQuery click() event so that when a checkbox is clicked it's value is returned through the .ajax() call into my aspx page.

The aspx page uses this value in one of my database methods to get a datatable of results for this value. I then assign this to my GridView control through .DataSource and bind the data using .DataBind().

But nothing happens. I have debugged the code and the call to the database was successful and I can see the data in the DataTable.

When I use this DataTable to create an HTML table it works. But is there anyway that I can get to populate the GridView control?
# re: jQuery and ASP.NET Article Part 2 Posted
by JoeReynolds March 29, 2009 @ 11:09am
One thing seems to always be missing from the demos. It is code that allows use of jquery to page through dataset info.

I'm hopeful of seeing a demo, perhaps using Northwind, of something like the ability to page through products, one or more products at a time, where users with javascript enabled get the ajax response via json (with history), and those without javascript automatically get a normal url page refresh.

I've been looking for such a demo for MVC but not found anything. I did find a jquery plugin call Ajaxify that does such paging but would prefer to see some code from MS.
# re: jQuery and ASP.NET Article Part 2 Posted
by prabhjot singh April 16, 2009 @ 5:08am
hi there,

I want to call a jquery function from my .cs page. I have made a plugin called jquery.xyz.js.
I have registered it on my aspx page. i have made a function in this plugin as follows :

$.extend($.fn, {
SelectMenuProcess: function(MainElemID) {
return this.each(function() {
document.getElementById("check").className = "section-" + MainElemID;

});

}
});

Iam calling this function from the .cs page as follows:

this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "startup", "<script type=\"text/javascript\">SelectMenuProcess('" + Request["Tab"] + "');</script>");

When i execute this code, firebug shows error ie "SelectMenuProcess" is undefined.
I going wrong in plugin formation. Can you please help. i have gone through several articles like: http://docs.jquery.com/Plugins/Authoring etc

regards
prabhjot
# re: jQuery and ASP.NET Article Part 2 Posted
by Tom May 21, 2009 @ 4:43pm
Thanks Rick,

This article is very good!!!

cheerio.
# re: jQuery and ASP.NET Article Part 2 Posted
by Muzikayise June 09, 2009 @ 4:56am
Hi Rick,

Thanks buddy, these are great articles with regards to JQuery and ASP.NET.

A mate of mine had said to me that after using JQuery and ASP.NET together, it changed his entire view on ASP.NET and i think these articles will enable me understand better how the 2 come together. Thank you

Best

Muzi
# re: jQuery and ASP.NET Article Part 2 Posted
by sercan June 26, 2009 @ 8:51am
does anybody try to get book items when no book item is available after all items been deleted. it's "length cannot be less than zero." error show up."

is it possible to return empty list rather than null value coz null value returned causes onerror method to be triggred on client side.
# re: jQuery and ASP.NET Article Part 2 Posted
by Dinesh Kumar Mandal August 29, 2009 @ 12:07pm
I read both the articles: Part 1 & 2. I must confess these are the best reference articles on ASP.Net with jQuery. Great work....!
# re: jQuery and ASP.NET Article Part 2 Posted
by John February 23, 2010 @ 1:11pm
If I know I am using unique IDs I like to use the jQuery attribute "ends with" selector $('[id*=MY_ID]') - really this is only useful if you are making truly unique IDs.

Hopefully this is useful to some :)
# re: jQuery and ASP.NET Article Part 2 Posted
by Amit February 26, 2010 @ 5:08am
You are awesome ... great work done
# re: jQuery and ASP.NET Article Part 2 Posted
by aspfun June 23, 2010 @ 12:17pm
Thank you, Rick.
I spent whole day to search jquery with asp.net sample and article, yours is the top one.
From here, I'll start to learn jquery.
I downloaded zip file from www.west-wind.com/files/conferences/jQuery.zip.
There are no PhotoAlbum and WcfAjax two projects.
Where to download PhotoAlbum and WcfAjax two projects?
# re: jQuery and ASP.NET Article Part 2 Posted
by Aritra July 28, 2010 @ 6:21am
Super Cool!!!
:)

I have always found your blogs helpful.
I was looking for JQuery Templating stuff and again found yours to be the best.
Keep up the good work.
Good stuff!!
# re: jQuery and ASP.NET Article Part 2 Posted
by Denise September 21, 2010 @ 11:16am
I used the information from your article today to grab an html string from a page so that it could be used to output a pdf using MVC. Thanks for posting this information. I have you used your pages several other times in the past.

<script language="javascript" type="text/javascript">
        $(this).ready(function() {
            $("#GetPdf").click(function() {
            theHtml = $("html").html()
                $.download('<%= Url.Action("AgreementDetailsPdfReport","Reports") %>', { filename: "AgreementDetails", format: "pdf", html_: theHtml }, "post");
            });
        });
    </script>
# re: jQuery and ASP.NET Article Part 2 Posted
by Pete Wojtkowiak October 20, 2010 @ 6:14am
Freaking fabulously well-written. Thanks a million for your efforts. It has helped me to finally "get it"! I have been a JS hater for a long time and this will bridge the divide for me.
# re: jQuery and ASP.NET Article Part 2 Posted
by Joy January 24, 2011 @ 9:23pm
Hi Rick, I'm stuck with this getJSON() and can't get it working properly, I followed your instructions but...
Here's my code,
Server Side:
public void GetClient(Guid clientId)
{
InformationEntities context = new InformationEntities();
var query = from c in context.Clients
where c.ClientID == clientId
select new {
c.FirstName,
c.MiddleName,
c.LastName,
c.Locality,
c.LandPhone,
c.CellPhone,
c.DOB,
c.Email,
c.IsActive,
c.PAN,
c.TAN,
c.Remarks,
c.BankAccount
};
System.Web.Script.Serialization.JavaScriptSerializer ser = new System.Web.Script.Serialization.JavaScriptSerializer();

String res = ser.Serialize(query);
context.Dispose();
Response.ContentType = "application/json";
Response.Write(res);
Response.End();
}

Client Side:
function PopulateFormFields(){
$.getJSON("EditClient.aspx",{clientId:qs}, function(data){
$("#FirstName").text(data.FirstName);
});
}

The page on response just tries to save the returned JSON object :'(
Can't figure out what is wrong, can you have a look?

Regards,
Joy
# re: jQuery and ASP.NET Article Part 2 Posted
by Prashant June 21, 2012 @ 2:29am
Hi Rick,

Great Articles. Will be great if u can the link to3rd article
 


West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2014