Mark's Stuff

My Foray Into Weblogging. Using this to store interesting items for later review.

Friday, October 17, 2008

What is jQuery?

I first heard of jQuery when Microsoft (actually, Scott Guthrie, the Microsoft VP for Developer Division) announced support for it (see the link below). Then, the .Net Developer User Group had a session on it last week. This is something simple, easy to implement and add to our toolkit, and can save a ton of time adding desirable features to our websites.

If you have not heard about jQuery before:

  • JavaScript library, just link a javascript file to your web page to enable it.
    e.g. : <script type="text/javascript" src="../jquery.min.js"></script>
  • a lightweight JavaScript library, only 15kb in size.
  • Licensed under GPL or MIT (any and all use is free, commercial or otherwise permitted)
  • supported browsers: Firefox 1.5+, Internet Explorer 6+, Safari 2.0.2+, Opera 9+

Good beginning description of it from Scott Guthrie’s blog (http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx):

A big part of the appeal of jQuery is that it allows you to elegantly (and efficiently) find and manipulate HTML elements with minimum lines of code.  jQuery supports this via a nice "selector" API that allows developers to query for HTML elements, and then apply "commands" to them.  One of the characteristics of jQuery commands is that they can be "chained" together - so that the result of one command can feed into another.  jQuery also includes a built-in set of animation APIs that can be used as commands.  The combination allows you to do some really cool things with only a few keystrokes.

For example, the below JavaScript uses jQuery to find all <div> elements within a page that have a CSS class of "product", and then animate them to slowly disappear:

clip_image002

As another example, the JavaScript below uses jQuery to find a specific <table> on the page with an id of "datagrid1", then retrieves every other <tr> row within the datagrid, and sets those <tr> elements to have a CSS class of "even" - which could be used to alternate the background color of each row:

clip_image004

Microsoft will be bundling and supporting jQuery from now on

Again from Scott Guthrie’s blog:

  • “Microsoft will be shipping jQuery with Visual Studio going forward”
  • “We will distribute the jQuery JavaScript library as-is, and will not be forking or changing the source from the main jQuery branch.  The files will continue to use and ship under the existing jQuery MIT license.”
  • “will also distribute intellisense-annotated versions that provide great Visual Studio intellisense and help-integration at design-time.”
  • “add the jQuery library by default to all new projects.”
  • “We will also extend Microsoft product support to jQuery beginning later this year, which will enable developers and enterprises to call and open jQuery support cases 24x7 with Microsoft PSS.”
  • “Going forward we'll use jQuery as one of the libraries used to implement higher-level controls in the ASP.NET AJAX Control Toolkit.”

Here are some links on jQuery:

· http://jquery.com/

· Download: http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.6.min.js&downloadBtn=%3CSPAN%3EDownload%3C%2FSPAN%3E

· Documentation: http://docs.jquery.com/Main_Page

· Tutorials: http://docs.jquery.com/Tutorials

· Scott Hanselmann’s tutorial using jQuery in Visual Studio and Ajax and ADO.Net Data Services: http://www.hanselman.com/blog/jQuerytoshipwithASPNETMVCandVisualStudio.aspx

Labels: , ,

Wednesday, April 23, 2008

Cleveland Day of .Net 2008

Cleveland Day of .NET

Labels: ,

Wednesday, May 23, 2007

Get Calling MethodName

A question came up in last night VB.Net User Group about how to get the calling method when using a common exception handling method. I remembered I did it somewhere before, but could not even remember any part of it to look up at the time. So I post it here and will send it to Sam for posting to the SIG blog.


Basically, you instantiate a System.Diagnostics.StackTrace object with the StackTrace from the Exception object, then get the MethodName from that. Here is an example using a Console app:



Imports System.Diagnostics
Imports system.reflection
Module Module1
  Sub Main()
    Try
      Throw New ApplicationException("HAHA")
    Catch ex As Exception
      ProcessException(ex)
    End Try
  End Sub

  Sub ProcessException(ByVal ex As Exception)
    Dim stackTrace As StackTrace = New StackTrace(ex)
    Dim stackFrame As StackFrame = stackTrace.GetFrame(0)
    Dim methodBase As MethodBase = stackFrame.GetMethod()
    Console.WriteLine("Error in Method {0} ", methodBase.Name)
  End Sub
End Module


Also, you can instantiate the StackTrace object without any arguments, and it loads the current method. You can then get the calling method (or the entire CallStack of methods) at any point in your code by walking through the StackFrames.



Imports System.Diagnostics
Imports system.reflection
Module Module1
  Sub Main()
    A()
  End Sub

  Sub A()
    B()
  End Sub

  Sub B()
    C()
  End Sub

  Sub C()
    Dim stackTrace As StackTrace = New StackTrace()
    Console.WriteLine("Called By Method {0} ", stackTrace.GetFrame(1).GetMethod().Name)
    Console.WriteLine("Listing the Entire Stack Trace:")
    For Each stackframe As StackFrame In stackTrace.GetFrames()
      Console.WriteLine("Method {0} ", stackframe.GetMethod().Name)
    Next
  End Sub
End Module

Labels: , ,

Tuesday, January 23, 2007

.Net Developer Users SIG Links

List of talked about links from tonight's session of Cleveland .Net Developers SIG

  • MyGeneration - Code Generation, O/R Mapping, and Architectures
    http://www.mygenerationsoftware.com/portal/default.aspx

  • MindCrafted Systems, Inc.
    http://www.mindcrafted.com/
    http://www.clevelanddotnet.info/presentations/CodeGenerators.pdf

  • NHibernate for .NET
    http://www.hibernate.org/343.html

  • Microsoft patterns & practices Home
    http://msdn.microsoft.com/practices/

    Labels: ,

  •