1

I'm trying to get on with Script# library and find it challenging to get some jQuery based Ajax code written. Is there any beginner's tutorial or important API documentation that can get me started real quick?

3
  • Are you already comfortable with jQuery? Commented Apr 12, 2011 at 22:41
  • @DuckMaestro: I'm not that comfortable with jQuery and think that C# style coding converted into jQuery would boost my productivity. Commented Apr 13, 2011 at 5:40
  • unless you have very strict deadlines or only have a small piece of code to write with no maintenance, you will be better off learning jQuery instead. Commented Apr 13, 2011 at 10:35

2 Answers 2

6

Since you mentioned you're new to jQuery I would at least start with the jQuery documentation and get comfortable with the basics (see jQuery Documentation).

Once you are comfortable with jQuery, using it in Script# is fairly straight-forward because Script# already includes bindings for jQuery. To get started:

  1. Make sure you're including jQuery in your HTML page or templates, as you would normally for jQuery (e.g. <script src="[jQuery]"></script>).
  2. Verify your Script# project has a reference to Script.jQuery(.dll).
  3. Within your .cs source file(s) add using jQueryApi; (for convenience). This is the namespace containing Script#'s jQuery bindings.

Now you can utilize jQuery in your Script# code, in a fashion that maps fairly 1:1 to if you were using jQuery within JavaScript. The biggest difference though is in how you first create a jQuery object.

In JavaScript:

// selector
var paragraphs = $("p");    

// ad-hoc html
var someHtml = $("<strong>hello</strong>"); 

// existing DOM element
var elementFromDom = $(document.getElementById("myDiv"));

// ready callback
$(function() { doSomething(); });

In Script#/C#:

// selector
jQueryObject paragraphs = jQuery.Select("p");

// ad-hoc html
jQueryObject someHtml = jQuery.FromHtml("<strong>hello</strong>");

// existing DOM element
jQueryObject elementFromDom = jQuery.FromElement(Document.GetElementById("myDiv"));

// ready callback
jQuery.OnDocumentReady(delegate { DoSomething(); });
Sign up to request clarification or add additional context in comments.

Comments

3

Recently at MIX11, Nikhil Kothari, the creator of Script# delivered a very good session on Script# followed by a nice blog post covering how to use Script# with jQuery. This is perfect for the beginners. Below are the links for the video of the session and the followed blog post

video - http://channel9.msdn.com/Events/MIX/MIX11/HTM16

archived blog post - http://web.archive.org/web/20110421060154/http://www.nikhilk.net/ScriptSharp-MIX11.aspx

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.