A simple HTTP GET for the action with a filter of hou yields the expected results. in VS .NET

Printer Code 128 Code Set A in VS .NET A simple HTTP GET for the action with a filter of hou yields the expected results.

A simple HTTP GET for the action with a filter of hou yields the expected results.
USS Code 128 Creator In .NET
Using Barcode generator for ASP.NET Control to generate, create Code 128A image in ASP.NET applications.
www.OnBarcode.com
Creating QR Code ISO/IEC18004 In Visual Studio .NET
Using Barcode generation for ASP.NET Control to generate, create Denso QR Bar Code image in ASP.NET applications.
www.OnBarcode.com
Now that we re sure that the action is returning the correct results, we can test the text box. The JavaScript we added earlier hooks up to the keypress events on the text box and should issue queries to the server. Figure 27.4 shows this in action. Our autocomplete functionality works as intended, but the resulting text looks quite gaudy when exercised in the browser. The next section explains how to style the results so that the resulting data fits in with the UI of the application.
Draw ANSI/AIM Code 39 In Visual Studio .NET
Using Barcode printer for ASP.NET Control to generate, create Code 3/9 image in ASP.NET applications.
www.OnBarcode.com
Making Matrix In .NET
Using Barcode maker for ASP.NET Control to generate, create Matrix 2D Barcode image in ASP.NET applications.
www.OnBarcode.com
Figure 27.4 The results are displayed in a <ul> tag. We can apply CSS to make it look nicer.
UCC - 12 Creator In .NET
Using Barcode printer for ASP.NET Control to generate, create EAN / UCC - 14 image in ASP.NET applications.
www.OnBarcode.com
Creating UPCA In VS .NET
Using Barcode maker for ASP.NET Control to generate, create UPC A image in ASP.NET applications.
www.OnBarcode.com
Recipe: creating an autocomplete text box
Creating DataMatrix In .NET Framework
Using Barcode creation for ASP.NET Control to generate, create Data Matrix ECC200 image in ASP.NET applications.
www.OnBarcode.com
Code 93 Full ASCII Drawer In .NET Framework
Using Barcode maker for ASP.NET Control to generate, create Code 93 Extended image in ASP.NET applications.
www.OnBarcode.com
27.2 Styling the results
Print Code 128 Code Set A In None
Using Barcode maker for Office Excel Control to generate, create Code 128B image in Microsoft Excel applications.
www.OnBarcode.com
Encode Code 128C In None
Using Barcode encoder for Word Control to generate, create USS Code 128 image in Word applications.
www.OnBarcode.com
The drop-down selections are unformatted by default, which makes them a little ugly. CSS magic will make them look nicer. Listing 27.3 shows some sample CSS for this transformation.
Scan Barcode In VS .NET
Using Barcode recognizer for .NET framework Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Drawing EAN-13 In VB.NET
Using Barcode generation for VS .NET Control to generate, create European Article Number 13 image in .NET applications.
www.OnBarcode.com
Listing 27.3 CSS used to style the autocomplete results
Printing GS1 - 13 In Java
Using Barcode generator for Eclipse BIRT Control to generate, create European Article Number 13 image in BIRT applications.
www.OnBarcode.com
Barcode Encoder In Java
Using Barcode drawer for Eclipse BIRT Control to generate, create Barcode image in BIRT reports applications.
www.OnBarcode.com
<style type="text/css"> div.ac_results ul { margin:0; padding:0; list-style-type:none; border: solid 1px #ccc; } div.ac_results ul li { font-family: Arial, Verdana, Sans-Serif; font-size: 12px; margin: 1px; padding: 3px; cursor: pointer; } div.ac_results ul li.ac_over { background-color: #acf; } </style>
Decoding PDF 417 In None
Using Barcode reader for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Barcode Generation In Objective-C
Using Barcode creator for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com
The result of applying this CSS can be seen in figure 27.5. The options of the autocomplete plugin enable us to configure it to our needs. For the case that we ve shown here, it s as simple as this:
DataMatrix Scanner In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Draw Barcode In .NET Framework
Using Barcode creation for Visual Studio .NET Control to generate, create Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Figure 27.5 The styled drop-down results look much nicer. The selected item is highlighted and can be chosen with the keyboard or mouse.
Decode Data Matrix 2d Barcode In None
Using Barcode decoder for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Print Code 128 Code Set C In Java
Using Barcode generation for Android Control to generate, create Code128 image in Android applications.
www.OnBarcode.com
$(your_textbox).autocomplete('your/url/here');
The full list of options can be seen in table 27.1.
Table 27.1 Common options for the autocomplete plug-in Description This CSS class will be added to the input box. The CSS class to apply to the results container. The default value is ac_results.
Option
inputClass resultsClass
Summary
Table 27.1 Common options for the autocomplete plug-in (continued) Description
Option
loadingClass
The CSS class to apply to the input box while results are being fetched from the server. The default is ac_loading. The character used to separate the results. The default is \n. The minimum number of characters before sending a request to the server. The default is 1. The delay after typing when the request will be sent. The default is 400 ms.
lineSeparator minChars
Delay
To set these options, include them in a dictionary as the second argument to the autocomplete method, as shown in listing 27.4.
Listing 27.4 Adding options to the jQuery autocomplete plug-in
<script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script src="../../Scripts/jquery.autocomplete.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $("input#city").autocomplete( '<%= Url.Action("Find", "City") %>', { minChars : 3, delay : 300 }); }); </script>
This type of functionality is immensely useful for selecting from large lists. It keeps our initial page size down by not loading all these items at once, and it s user-friendly. Every scenario is unique, so be sure to tune the delay to match the nature of the data. This will ensure that the number of requests back to the server is kept to a manageable level.
27.3 Summary
In this chapter, we learned how to leverage a common jQuery plug-in to add autocomplete behavior to a view. We learned how to respond to Ajax requests and create a formatted response that the plug-in can consume. You should now be able to apply this technique to make your applications more responsive and helpful to your users. Many other useful helpers for specialized functionality are available from jQuery, as well as third-party component vendors. Armed with your knowledge of creating ASP.NET MVC applications, you re now well equipped to deliver top-notch web-based software that not only delivers one-of-a-kind features but also incorporates the best components available for ASP.NET MVC. Happy coding!
index
Numerics
32-bit 362 404 240 242, 247, 351, 354 64-bit 357, 363 ActionNameAttribute 238, 370 ActionNameSelectorAttribute 369 ActionResult 50 51, 53 55, 58, 127, 130, 132 134, 238, 240 242, 304, 309 310, 369 370, 372 373 Activator.CreateInstance 191 Add Area wizard 302 Add Controller 10 Add View 11, 19 20 Add View dialog 357, 359 360 Add Web Site 82 Add/Edit Application Extension Mapping 86, 88 administration sections 301 adonet.batch_size 329 aggregate 120, 122 126 boundaries 124 root 122 123 AJAX 167 179, 181 182, 184 189, 236, 244 definition of 167 from scratch 168 helpers 173, 186 HttpHandler 171 no-touch 179 request has extra HTTP header 179 return values 172 simple example 168 with ASP.NET MVC 172 with JSON 181 with Web Forms 170 with XML 181 Ajax.ActionLink 186 Ajax.BeginForm 173, 187 AjaxHelper 35, 138 AjaxOptions 187 188 alternate path 52, 55, 58 59, 65 anonymous type 237, 240 Apache 228, 230 ApartmentState 287 289 App_GlobalResources 112 App_LocalResources 114 application architects 278 application bus 268, 278 282 application logic 230 231 application pool 83 Application_Start 183, 194, 198 199, 201, 220 area 301 302, 312 313, 315 321 area registration 302 304 area registration class 302 AreaName 303, 307 AreaRegistration 303 304, 315 Areas folder 302 ASP.NET Ajax 215, 221 222, 224 ASP.NET MVC, alternative to Web Forms 95 ASP.NET Routing Debugger 355 aspect-oriented programming 129 .aspx extension 84 86 assembly 312 314, 316, 320 321 assertion negative 372 assertions 364, 370 AssociatedMetadataProvider 219
abstract factories 325 Accepting Input 54 AccountController 212 213, 312 313 action 8, 50 62, 64 65, 127, 129, 131, 133 135, 230 231, 233, 235 245, 313 filter 129 131, 283, 365, 379 testing 364, 376 invokers 283 methods 52 naming 369 parameters 203 results 127, 268, 276 277, 281 selectors 127, 131 single responsibility 51 ActionExecutedContext 377 ActionExecutingContext 377 379 ActionFilter 129 ActionFilterAttribute 129 ActionLink 138, 141 142, 144, 148 149, 243 244, 305 307, 310 ActionMethodSelector 131 ActionMethodSelectorAttribute 369
388 Asynchronous JavaScript and XML. See AJAX attack 152, 155 160, 163 attribute 272 auditing 281 authentication 152 155, 166, 312 authorization 129, 152 155, 166 AuthorizationContext 377 Authorize 130, 153 154 AuthorizeAttribute 153 155, 161, 166 autocomplete 380 autocomplete plugin, filters local data structures 382 AutoGenerateColumns 67 68, 77 AutoMapper 258 260, 262 267, 276 277 AutoMapperConfigurationTester 265 AutoMapViewResult 277 automated deployment process 251 automated integration 252 automated test cases 364 automated testing 59 automated tests 5, 364, 379 automated user interface tests 284 automating deployment 252 automating the build 252 automation 251, 257, 284, 289, 356 autonumber 234
Copyright © OnBarcode.com . All rights reserved.