Skip to main content

Home/ .Net Developers/ Group items tagged quotes

Rss Feed Group items tagged

Tarik Guney

Using jQuery with ASP.NET: Part 2 - Making Ajax Callbacks to the Server - 1 views

  • $.getJSON(url,data,callback) Similar to $.post(), but expects the result to be JSON which is automatically deserialized into a Javascript value and passed to the callback as a parameter.
  • $.getJSON() also doesn’t support JSON POST data – only POST encoded variables
  • Specifically inside of a master page you might find that the ID gets mangled by ASP.NET into: ctl00_Content_txtSymbol. I could change my code to read: { symbol: $("#ctl00_Content_txtSymbol").val() }   which works, but is pretty ugly and volatile because the parent IDs might change if a container is renamed or moved around.   Another option is to use a little server side script markup to embed the ClientID: { symbol: $("#<%= txtSymbol.ClientID %>").val() } This is also ugly, but reliable. But this does not work if you end up moving your code into a separate .js script file. If you use client ids like this a lot you might create a list of them as global variables:   var txtSymbolId = "<%= txtSymbol.ClientID %>"; which then lets you reuse the variable a little more easily:   { symbol: $("#" + txtSymbolId).val() }   These variables are also visible in loaded script files.
  • ...4 more annotations...
  • $.getScript(url,callback) This function loads script code from the server and executes it once downloaded if no callback is specified
  • An optional callback can be provided to be notified with the server result text when the callback completes which is useful if you want to visually adjust the retrieved content – like applying an effect to visually cue the user to an update. Note this function is heavily overloaded: If no URL is specified .load() acts as a load event handler that fires when an element has loaded its data (ie. an image or script).
  • This function is useful for simple JSON results returned from arbitrary services, but not usable for calling WCF or ASMX ASP.NET services since they expect JSON POST input
  • here also a number of global Ajax events that you can take advantage of all of which take callbacks as parameters: ajaxCallback(), ajaxError(), ajaxSend(), ajaxStart(),ajaxStop(),ajaxSuccess(). These are useful for setting up global handlers that can centrally manage Ajax requests. You’re not likely to need these much unless you build components that need to know status of requests.
  •  
    Rick Strahl is introducing the best document ever, how to make ajax callbacks to asp.net applications ( asmx,wcf and asp.net) this article shows us how easy to use jQuery Ajax with asp.net and how powerful over Asp.NET Ajax Framework.
Tarik Guney

Great programming quotes - Stack Overflow - 0 views

  • Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
  • Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live
  • It works on my machine.
  •  
    The best code QA method.
1 - 2 of 2
Showing 20 items per page