Danh mục

Apress Introducing dot NET 4 0 with Visual Studio 2010_6

Số trang: 45      Loại file: pdf      Dung lượng: 1.74 MB      Lượt xem: 11      Lượt tải: 0    
Jamona

Hỗ trợ phí lưu trữ khi tải xuống: 6,000 VND Tải xuống file đầy đủ (45 trang) 0

Báo xấu

Xem trước 5 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Nếu bạn không muốn hiệu quả của việc mã jQuery tay ​​của bạn, bạn có thể sử dụng một công cụ tuyệt vời Glimmer được gọi là sản xuất bởi Microsoft cung cấp một cách tiếp cận dựa trên hướng dẫn
Nội dung trích xuất từ tài liệu:
Apress Introducing dot NET 4 0 with Visual Studio 2010_6 CHAPTER 12 JQUERY Additional Effects In addition to the previous effects, a number of additional effects can be downloaded: fold, pulsate, puff, bounce, and explode (my personal favorite). For more details on these effects please go to http://docs. jquery.com/UI/Effects. Glimmer If you don’t want to hand-code your jQuery effects, you can use a great tool called Glimmer produced by Microsoft that offers a wizard-based approach (see Figure 12-4). Refer to http://visitmix.com/lab/ glimmer. Figure 12-4. Glimmer allows you to easily construct jQuery effects Glimmer allows the construction of simple effects such as rotating images, drop-down menus, and animation. jQuery Tools jQueryPad ( (http://www.paulstovell.com/jquerypad) and http://jsbin.com/ can be very useful tools for prototyping and playing with jQuery.282 CHAPTER 12 JQUERYChaining EventsThe real power of jQuery comes from its capability to chain functions together. Imagine that we wantedto fade our div in and out a number of times. This procedure can be easily accomplished with thefollowing code:$(#div1).fadeOut().fadeIn().fadeOut().fadeIn().fadeOut();Customizing jQueryYou can add your own functions to the jQuery library. For example, to create a simple function that willpop up an alert box, you can do so with the following code://dont use $ alias in case user overrides itjQuery.fn.say = function (message) { alert(jQuery says + message); return this;} You can then call the new function with the following code:$.fn.say(hello).say(good bye); And there is, of course, no reason why you couldn’t write a new effects function and use it as part ofa chain of effects. For more information, please refer to http://docs.jquery.com/Plugins/Authoring.AJAX MethodsIt is very common for performance optimization to need to retrieve data or code from an external sourceafter a page is loaded. jQuery makes this very easy.Load and Run JavaScript FileThe following code loads an external JavaScript file called test.js and then executes it:$.ajax({ type: GET, url: test.js, dataType: script}); The test.js file consists of just the following line:alert(hello); 283 CHAPTER 12 JQUERY Submitting Data You often need to submit data to another web page. This can easily be done with the following code: $.ajax({ type: POST, url: myForm.aspx, data: firstname=Alex&lastname=Mackey, success: function() { alert(form submitted); } }); You will use this functionality in the ASP.NET MVC example (see Chapter 13) to submit your form data: //Submit client side $.ajax({ type: POST, dataType: json, url: Edit, data: { Description: InputDescription, Length: InputLength, DateShowing: InputDateShowing }, success: function(result) { alert(result.Message + adding film at + result.DateShowing); }, error: function(error) { alert(error ); } }); Getting the Latest Version of a Page We can retrieve the contents of a page in the same domain as the calling page with a few lines of code. This could be useful in AJAX scenarios in which you want to load content behind the scenes: $.ajax({ url: default2.aspx, cache: false, success: function(returnHtml) { $(#div1).append(returnHtml); } });284 CHAPTER 12 JQUERYRetrieving a JSON ObjectJSON is a compact format for representing data. jQuery contains support for working with JSON objects.We will first create a page called default2.aspx t hat will return a JSON-formatted string (you will soonlook at a better way of doing this). Right-click your solution and add a new page called default2.aspx and select the place code in 1. a seperate file option. Remove all the code on default2.aspx except for the page declaration. 2. Add the following code to default2.aspx.cs: 3. protected void Page_Load(object sender, EventArgs e) { Response.Buffer = true; Response.Clear(); Response.ContentType = application/json; Response.Write({firstName: Alex,lastName: Mackey}); } Open default.htm ...

Tài liệu được xem nhiều: