Search Results

Search found 3171 results on 127 pages for 'manual manuel'.

Page 82/127 | < Previous Page | 78 79 80 81 82 83 84 85 86 87 88 89  | Next Page >

  • How is the implicit segment register of a near pointer determined?

    - by Daniel Trebbien
    In section 4.3 of Intel 64® and IA-32 Architectures Software Developer's Manual. Volume 1: Basic Architecture, it says: A near pointer is a 32-bit offset ... within a segment. Near pointers are used for all memory references in a flat memory model or for references in a segmented model where the identity of the segment being accessed is implied. This leads me to wondering: how is the implied segment register determined? I know that (%eip) and displaced (%eip) (e.g. -4(%eip)) addresses use %cs by default, and that (%esp) and displaced (%esp) addresses use %ss, but what about (%eax), (%edx), (%edi), (%ebp) etc., and can the implicit segment register depend also on the instruction that the memory address operand appears in?

    Read the article

  • Error when creating database in MySQL using Netbeans 6.8

    - by nix
    I am trying to create a database using MySQL statements in NetBeans 6.8. However, I keep getting Error code 1064. I don't know what the problem is really since the same statements work in NetBeans 6.0. Here is the error: Error code 1064, SQL state 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; /*!40000 ALTER TABLE students ENABLE KEYS */; -- -- Definition of table `w' at line 1016 Line 46, column 1

    Read the article

  • Java PreparedStatement Throws MySQLSyntaxErrorException

    - by sqlBugs
    I have the following Java code: String query = "Select 1 from myTable where name = ? and age = ?"; PreparedStatement stmt = conn.prepareStatement(query); stmt.setString(1, name); stmt.setInt(2, age); ResultSet rs = stmt.executeQuery(); Whenever I run the above code, it throws an exception on line 2 (where the PreparedStatement is declared): Error 0221202: SQLException = com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? AND age = ?' at line 1 Does anyone have any suggestions about what I am doing wrong? Thanks!

    Read the article

  • Directions and Opinions on Creating Update System for the Application.

    - by AlwaysBeCoding
    Hi people. I just try to figure out a good solution on designing the update process for a windows form application i created. I think of a button inside the app for manual checking of an update and checking when starting the app. Only I'm not familiar with technics. I though to have the update setup file in a FTP Server and checking the server for an update with a txt file in there with filename and version info. When app is finished downloading the update, closing and starting the update setup file. Any suggestions, opinions on the subject?

    Read the article

  • MySQL Check if table exists error

    - by Max van Heiningen
    I'm trying to check if a table already exists, however I can't get this working. IF EXISTS (SELECT 1 FROM sysobjects WHERE xtype='u' AND name='tablename') SELECT 'table already exists.' ELSE BEGIN CREATE TABLE Week_( id INT(10)AUTO_INCREMENT PRIMARY KEY (id), ... ...) END; My error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF EXISTS (SELECT 1 FROM sysobjects WHERE xtype='u' AND name' at line 1 Can someone help me with this? Thanks in advance

    Read the article

  • Sql Server query performance

    - by Macros
    I have a stored procedure on a busy database which constantly come out top in the list of expensive queries (by some way). The query is very simple, it takes a single parameter (@ID, int) which is the primary key of the table, and selects the record that matches that ID. The primary key is an identity field with a clustered index, so I am stumped as to how to optimise this any further? The query is as follows CREATE PROCEDURE [dbo].[P_Call_Get] @ID int = null AS select ID, AppID, AgentID, AgentLogin, Ext, VDN, VDNName, Skill, SkillName, CallFrom, TelNoFrom, ParentCallID, CallStart, ACWStart, CallEnd, Outcome, StageID, TxTo, TxSuccess, ServiceID, DiallerID, CRC, TSCallID, CallDirection, [Manual], CallBackAgent, CallBackDateTime, Notes from P_Call where (ID = @ID or @ID is null) Not sure the best way to post the execution plan - all it shows is that 100% of the operation is taken up by the clustered index scan

    Read the article

  • Queues And Wait Handles in C#

    - by Michael Covelli
    I've had the following code in my application for some years and have never seen an issue from it. while ((PendingOrders.Count > 0) || (WaitHandle.WaitAny(CommandEventArr) != 1)) { lock (PendingOrders) { if (PendingOrders.Count > 0) { fbo = PendingOrders.Dequeue(); } else { fbo = null; } } // Do Some Work if fbo is != null } Where CommandEventArr is made up of the NewOrderEvent (an auto reset event) and the ExitEvent (a manual reset event). But I just realized today that its not thread safe at all. If this thread gets interrupted right after the first (PendingOrder.Count 0) check has returned false. And then the other thread both enqueues an order and sets the NewOrderEvent before I get a chance to wait on it, the body of the while loop will never run. What's the usual pattern used with a Queue and an AutoResetEvent to fix this and do what I'm trying to do with the code above?

    Read the article

  • How can I duplicate, or copy a Core Data Managed Object?

    - by 106480833665852483906
    I have a managed object ("A") that contains various attributes and types of relationships, and its relationships also have their own attributes & relationships. What I would like to do is to "copy" or "duplicate" the entire object graph rooted at object "A", and thus creating a new object "B" that is very similar to "A". To be more specific, none of the relationships contained by "B" (or its children) should point to objects related to "A". There should be an entirely new object graph with similar relationships intact, and all objects having the same attributes, but of course different id's. There is the obvious manual way to do this, but I was hoping to learn of a simpler means of doing so which was not totally apparent from the Core Data documentation. TIA!

    Read the article

  • Would it be possible for web browsers to automatically update rendering engines?

    - by unknowing
    As a way to prevent the major annoyances of browser segmentation and older versions. This way the code would only need to be done for the latest version of the browser, but users could still have the functionality of the older version and not be forced to do major updates? I am sure there will be some major flaws in this, and I would like you to tell me what they are! -Obviously, people may not want this as often auto-updating is frowned upon, however Chrome does it (or at least, they used to); Without a manual check, Chrome will update itself automatically, Google said. "Google Chrome will automatically checks for updates approximately every five hours. If an update is available, it will be downloaded and applied at the next browser restart," Google said. -there is still the problem of getting users from the really old ones onto the any new browsers that have this functionality -To prevent exploits in terms of updates, maybe they could have a 7 day opt-in period before being pushed out to everyone?

    Read the article

  • Can't figure out what's wrong with my php/sql statement

    - by Olegious
    So this is probably a dumb beginner question, but I've been looking at it and can't figure it out. A bit of background: just practicing making a web app, a form on page 1 takes in some values from the user, posts them to the next page which contains the code to connect to the DB and populate the relevant tables. I establish the DB connection successfully, here's the code that contains the query: $conn->query("SET NAMES 'utf9'"); $query_str = "INSERT INTO 'qa'.'users' ('id', 'user_name','password' ,'email' ,'dob' ,'sx') VALUES (NULL, $username, $password, $email, $dob, $sx);"; $result = @$conn->query($query_str); Here's the error that is returned:Insert query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''qa'.'users' ('id', 'user_name' ,'password' ,'email' ,'dob' ,'s' at line 1 Thanks in advance!

    Read the article

  • Install a certficate on a device

    - by Vaccano
    I need to install a certificate on a Windows Mobile device. I have tried creating a cab file to do it, but the cab file fails to run. I have a lot of devices that are not all physically near me that I am going to need to put this on, so any manual process is just not feasible (ie, if it needs active sync then it is not going to work). Any ideas on how to do this? Visual Studio does not seem to support what I am trying to do.

    Read the article

  • Calling R Script from within C-Code

    - by tiny81
    Hi, Is there a way to call an R-Script within C-Code? I did find the R Api for C (chaper 6. of the 'Writing R Extensions' manual), but as far as I understood this does "only" allow to call the C-Implementation of R. Of cause I could call the R-Script via shell, but that's no solution for me, since this does not allow proper passing of data (at least no if I don't what to write the data into a Csv-File or something like this). Is there a easy way of using the R to C parser beforehand? Any hints you can give me? regards, Tiny

    Read the article

  • Linux rpm installs but cannot erase. Why?

    - by rmosley
    My Perl code installed several (4) rpm files as root. the next install removes them (rpm -e) before installing a newer version. One does not remove, with rpm -e giving the error that it is not installed. However, later when the updated file is installed, the message is given that it is already installed. Manual attempts to remove give the same results. My questions are how to force removal something from the rpm database, and why does this contradication exist (not installed from rpm -e and already installed from rpm -Uvh and rpm -ivh)?

    Read the article

  • DocumentBuilder.parse() / Parsing Entities

    - by stormin986
    I'm new to parsing XML and am having an issue with entities. (Am doing this on Android, if it makes a difference). Is there a way to have it turn an entity into the character it represents? I have this in the child of an element: "isn&#39;t" (minus quotes). I would prefer it parse it and the end result be a single text node. However, right now this is turned in to TEXT, ENTITY, TEXT. Is there a way to automatically have it parse the entity into text, or a manual way to do it?

    Read the article

  • Extracting ID from data packet GPS

    - by user604134
    Hi , I am trying to configure a GPS device to my systems. The GPS device send the data packet to my IP in the following format : $$?W??¬ÿÿÿÿ™U042903.000,A,2839.6408,N,07717.0905,E,0.00,,230111,,,A*7C|1.2|203|0000÷ I am able to extract the latitude, longitude and other information but I am not able to extract the Tracker ID out of the string. According to the manual the ID is in hex format.And the format of the packet is $$\r\n I dont know what to do with it, I have tried converting this to hex..but it didnt work. Any help will be greatly appreciate. Thanks

    Read the article

  • Why my query is not working?

    - by Poma
    my website has PHP command: mysql_query("SELECT * FROM users WHERE id=" . $_GET["id"]) or die(mysql_error()); When I enter URL http://example.com/index.php?id=1;%20UPDATE%20users%20SET%20password=123%20WHERE%20id=1 I get following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE users SET password=abc WHERE id=1' at line 1 But in phpmyamin query executes successfully. What's wrong here? Why it doesn't execute in browser?

    Read the article

  • Problems deleting cookies, won't unset (PHP).

    - by RemiX
    I've tried searching the php manual and internet on how to delete cookies and I've tried it the exact same way they all say: setcookie("name", '', 1); or setcookie("name", '', time()-3600); But when I check the cookies in the cookies dialog in Firefox, it's still there with the same value. I set this cookie using the following line: setcookie("name", $value, time() + 259200, $path); I found this question on stackoverflow: http://stackoverflow.com/questions/2497501/cookie-wont-unset, but none of the answers solved the problem. I also tried putting all paramaters in, like the author said, but it had no effect. Does anyone see the problem?

    Read the article

  • Matplotlib Contour Clabel Location

    - by jotimaz
    I would like to control the location of matplotlib clabels on a contour plot, but without utilizing the manual=True flag in clabel. For example, I would like to specify an x-coordinate, and have labels created at the points that pass through this line. I see that you can get the location of the individual labels using get_position(), but I am stuck at that. Any help would be greatly appreciated. Thanks! EDIT: The above image is an example plot that I would like to apply this method to. The default label positions are inconvenient -- the flat areas between Day 2 and Day 4 would be more visually appealing.

    Read the article

  • What does the R function `poly` really do?

    - by merlin2011
    I have read through the manual page ?poly (which I admit I did not completely comphrehend) and also read the description of the function in book Introduction to Statistical Learning. My current understanding is that a call to poly(horsepower, 2) should be equivalent to writing horsepower + I(horsepower^2). However, this seems to be contradicted by the output of the following code. library(ISLR) summary(lm(mpg~poly(horsepower,2), data=Auto))$coef summary(lm(mpg~horsepower+I(horsepower^2), data=Auto))$coef Output: Estimate Std. Error t value Pr(>|t|) (Intercept) 23.44592 0.2209163 106.13030 2.752212e-289 poly(horsepower, 2)1 -120.13774 4.3739206 -27.46683 4.169400e-93 poly(horsepower, 2)2 44.08953 4.3739206 10.08009 2.196340e-21 Estimate Std. Error t value Pr(>|t|) (Intercept) 56.900099702 1.8004268063 31.60367 1.740911e-109 horsepower -0.466189630 0.0311246171 -14.97816 2.289429e-40 I(horsepower^2) 0.001230536 0.0001220759 10.08009 2.196340e-21 My question is, why does the output not match, and what is poly really doing?

    Read the article

  • How to crosscheck two tables and insert relevant data into a new table in MYSQL?

    - by JackDamery
    I'm trying to crosscheck a row that exists in two tables using a MYSQL query in phpmyadmin and then if a userID is found in both tables, insert their userID and user name into another table. Here's my code: INSERT INTO userswithoutmeetings SELECT user.userID IF('user.userID'='meeting.userID'); I keep getting plagued by this error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF('user.userID'='meeting.userID')' at line 3 Other statements I've tried have worked but not deposited the values in the table.

    Read the article

  • Detecting when Javascript is performing poorly

    - by what-the-crap
    I'm working on a webapp in jquery that, on older machines or machines without much resources, may perform poorly. To get around this I'd like to make a degraded version that disables some of the features, particularly those that rely on large images. How can I tell if my app is running poorly on the user's computer in jquery or javascript in general? I just need a way to call a function that will degrade the app. (especially when the user may run low on system memory) The only way I can think of is for manual user intervention, but the option would add clutter for users that don't need it and users that do need it may not notice it. Thanks!

    Read the article

  • mysql querying age from dob

    - by Confused
    My MySQL database has date of birth stored in the format yyyy-mm-dd, how do I query the database - without using php code - to show me results of people born within x years of now, and/or, who are y years of age? The table is called users, the colum is called dob. I've spent a while viewing the MySQL manual but I can't work out precisely how to form my query. So far I went for select * from users where dob... but I don't think that's the way to go.

    Read the article

  • asp.net web application - server side canceling Submit PostBackUrl if not(!) Page.IsValid

    - by Brent
    Thanks for any help I have a web application, and the submit uses the PostBackUrl to display data if the form is valid. I need to use different (server side) validation groups, depending on what radiobutton is selected. That is, manually call Page.Validate('ValidationGroupA'). The validation itself is working fine, in terms of Page.IsValid correctly assigned true or false. however, if the page is not valid, the page redirects to the page specified by PostBackUrl on the submit button, where the page is found not to be valid, and the client redirected back with: if (!PreviousPage.IsValid){Response.Redirect("DataEntryPage.aspx");}) However, by getting to here and back again, all form data is lost, and the relevant validation controls and summaries are not displayed. is there an equivalent of javascripts evt.preventDefault() or some other way, once it is detected validation has failed after a manual call to Page.Validate to post the form back with appropriate validation errors displayed? Thank you.

    Read the article

  • MySql. What is there error on this insert+select+where statement?

    - by acidzombie24
    What is wrong with this statement? It works with sqlite and MS sql (last time i tested it) I would like a select unless there is no match with name or email. Then i would like to insert. I have it as one statement because its easy to keep concurrent safe as one statement. (its not that complex of a statement). INSERT INTO `user_data` ( `last_login_ip`, `login_date`, ...) SELECT @0, @14 WHERE not exists (SELECT * FROM `user_data` WHERE `name` = @15 OR `unconfirmed_email` = @16 LIMIT 1); Exception You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE not exists (SELECT * FROM `user_data` WHERE `name` = 'thename' OR `unconfirmed' at line 31

    Read the article

  • Microsoft and jQuery

    - by Rick Strahl
    The jQuery JavaScript library has been steadily getting more popular and with recent developments from Microsoft, jQuery is also getting ever more exposure on the ASP.NET platform including now directly from Microsoft. jQuery is a light weight, open source DOM manipulation library for JavaScript that has changed how many developers think about JavaScript. You can download it and find more information on jQuery on www.jquery.com. For me jQuery has had a huge impact on how I develop Web applications and was probably the main reason I went from dreading to do JavaScript development to actually looking forward to implementing client side JavaScript functionality. It has also had a profound impact on my JavaScript skill level for me by seeing how the library accomplishes things (and often reviewing the terse but excellent source code). jQuery made an uncomfortable development platform (JavaScript + DOM) a joy to work on. Although jQuery is by no means the only JavaScript library out there, its ease of use, small size, huge community of plug-ins and pure usefulness has made it easily the most popular JavaScript library available today. As a long time jQuery user, I’ve been excited to see the developments from Microsoft that are bringing jQuery to more ASP.NET developers and providing more integration with jQuery for ASP.NET’s core features rather than relying on the ASP.NET AJAX library. Microsoft and jQuery – making Friends jQuery is an open source project but in the last couple of years Microsoft has really thrown its weight behind supporting this open source library as a supported component on the Microsoft platform. When I say supported I literally mean supported: Microsoft now offers actual tech support for jQuery as part of their Product Support Services (PSS) as jQuery integration has become part of several of the ASP.NET toolkits and ships in several of the default Web project templates in Visual Studio 2010. The ASP.NET MVC 3 framework (still in Beta) also uses jQuery for a variety of client side support features including client side validation and we can look forward toward more integration of client side functionality via jQuery in both MVC and WebForms in the future. In other words jQuery is becoming an optional but included component of the ASP.NET platform. PSS support means that support staff will answer jQuery related support questions as part of any support incidents related to ASP.NET which provides some piece of mind to some corporate development shops that require end to end support from Microsoft. In addition to including jQuery and supporting it, Microsoft has also been getting involved in providing development resources for extending jQuery’s functionality via plug-ins. Microsoft’s last version of the Microsoft Ajax Library – which is the successor to the native ASP.NET AJAX Library – included some really cool functionality for client templates, databinding and localization. As it turns out Microsoft has rebuilt most of that functionality using jQuery as the base API and provided jQuery plug-ins of these components. Very recently these three plug-ins were submitted and have been approved for inclusion in the official jQuery plug-in repository and been taken over by the jQuery team for further improvements and maintenance. Even more surprising: The jQuery-templates component has actually been approved for inclusion in the next major update of the jQuery core in jQuery V1.5, which means it will become a native feature that doesn’t require additional script files to be loaded. Imagine this – an open source contribution from Microsoft that has been accepted into a major open source project for a core feature improvement. Microsoft has come a long way indeed! What the Microsoft Involvement with jQuery means to you For Microsoft jQuery support is a strategic decision that affects their direction in client side development, but nothing stopped you from using jQuery in your applications prior to Microsoft’s official backing and in fact a large chunk of developers did so readily prior to Microsoft’s announcement. Official support from Microsoft brings a few benefits to developers however. jQuery support in Visual Studio 2010 means built-in support for jQuery IntelliSense, automatically added jQuery scripts in many projects types and a common base for client side functionality that actually uses what most developers are already using. If you have already been using jQuery and were worried about straying from the Microsoft line and their internal Microsoft Ajax Library – worry no more. With official support and the change in direction towards jQuery Microsoft is now following along what most in the ASP.NET community had already been doing by using jQuery, which is likely the reason for Microsoft’s shift in direction in the first place. ASP.NET AJAX and the Microsoft AJAX Library weren’t bad technology – there was tons of useful functionality buried in these libraries. However, these libraries never got off the ground, mainly because early incarnations were squarely aimed at control/component developers rather than application developers. For all the functionality that these controls provided for control developers they lacked in useful and easily usable application developer functionality that was easily accessible in day to day client side development. The result was that even though Microsoft shipped support for these tools in the box (in .NET 3.5 and 4.0), other than for the internal support in ASP.NET for things like the UpdatePanel and the ASP.NET AJAX Control Toolkit as well as some third party vendors, the Microsoft client libraries were largely ignored by the developer community opening the door for other client side solutions. Microsoft seems to be acknowledging developer choice in this case: Many more developers were going down the jQuery path rather than using the Microsoft built libraries and there seems to be little sense in continuing development of a technology that largely goes unused by the majority of developers. Kudos for Microsoft for recognizing this and gracefully changing directions. Note that even though there will be no further development in the Microsoft client libraries they will continue to be supported so if you’re using them in your applications there’s no reason to start running for the exit in a panic and start re-writing everything with jQuery. Although that might be a reasonable choice in some cases, jQuery and the Microsoft libraries work well side by side so that you can leave existing solutions untouched even as you enhance them with jQuery. The Microsoft jQuery Plug-ins – Solid Core Features One of the most interesting developments in Microsoft’s embracing of jQuery is that Microsoft has started contributing to jQuery via standard mechanism set for jQuery developers: By submitting plug-ins. Microsoft took some of the nicest new features of the unpublished Microsoft Ajax Client Library and re-wrote these components for jQuery and then submitted them as plug-ins to the jQuery plug-in repository. Accepted plug-ins get taken over by the jQuery team and that’s exactly what happened with the three plug-ins submitted by Microsoft with the templating plug-in even getting slated to be published as part of the jQuery core in the next major release (1.5). The following plug-ins are provided by Microsoft: jQuery Templates – a client side template rendering engine jQuery Data Link – a client side databinder that can synchronize changes without code jQuery Globalization – provides formatting and conversion features for dates and numbers The first two are ports of functionality that was slated for the Microsoft Ajax Library while functionality for the globalization library provides functionality that was already found in the original ASP.NET AJAX library. To me all three plug-ins address a pressing need in client side applications and provide functionality I’ve previously used in other incarnations, but with more complete implementations. Let’s take a close look at these plug-ins. jQuery Templates http://api.jquery.com/category/plugins/templates/ Client side templating is a key component for building rich JavaScript applications in the browser. Templating on the client lets you avoid from manually creating markup by creating DOM nodes and injecting them individually into the document via code. Rather you can create markup templates – similar to the way you create classic ASP server markup – and merge data into these templates to render HTML which you can then inject into the document or replace existing content with. Output from templates are rendered as a jQuery matched set and can then be easily inserted into the document as needed. Templating is key to minimize client side code and reduce repeated code for rendering logic. Instead a single template can be used in many places for updating and adding content to existing pages. Further if you build pure AJAX interfaces that rely entirely on client rendering of the initial page content, templates allow you to a use a single markup template to handle all rendering of each specific HTML section/element. I’ve used a number of different client rendering template engines with jQuery in the past including jTemplates (a PHP style templating engine) and a modified version of John Resig’s MicroTemplating engine which I built into my own set of libraries because it’s such a commonly used feature in my client side applications. jQuery templates adds a much richer templating model that allows for sub-templates and access to the data items. Like John Resig’s original Micro Template engine, the core basics of the templating engine create JavaScript code which means that templates can include JavaScript code. To give you a basic idea of how templates work imagine I have an application that downloads a set of stock quotes based on a symbol list then displays them in the document. To do this you can create an ‘item’ template that describes how each of the quotes is renderd as a template inside of the document: <script id="stockTemplate" type="text/x-jquery-tmpl"> <div id="divStockQuote" class="errordisplay" style="width: 500px;"> <div class="label">Company:</div><div><b>${Company}(${Symbol})</b></div> <div class="label">Last Price:</div><div>${LastPrice}</div> <div class="label">Net Change:</div><div> {{if NetChange > 0}} <b style="color:green" >${NetChange}</b> {{else}} <b style="color:red" >${NetChange}</b> {{/if}} </div> <div class="label">Last Update:</div><div>${LastQuoteTimeString}</div> </div> </script> The ‘template’ is little more than HTML with some markup expressions inside of it that define the template language. Notice the embedded ${} expressions which reference data from the quote objects returned from an AJAX call on the server. You can embed any JavaScript or value expression in these template expressions. There are also a number of structural commands like {{if}} and {{each}} that provide for rudimentary logic inside of your templates as well as commands ({{tmpl}} and {{wrap}}) for nesting templates. You can find more about the full set of markup expressions available in the documentation. To load up this data you can use code like the following: <script type="text/javascript"> //var Proxy = new ServiceProxy("../PageMethods/PageMethodsService.asmx/"); $(document).ready(function () { $("#btnGetQuotes").click(GetQuotes); }); function GetQuotes() { var symbols = $("#txtSymbols").val().split(","); $.ajax({ url: "../PageMethods/PageMethodsService.asmx/GetStockQuotes", data: JSON.stringify({ symbols: symbols }), // parameter map type: "POST", // data has to be POSTed contentType: "application/json", timeout: 10000, dataType: "json", success: function (result) { var quotes = result.d; var jEl = $("#stockTemplate").tmpl(quotes); $("#quoteDisplay").empty().append(jEl); }, error: function (xhr, status) { alert(status + "\r\n" + xhr.responseText); } }); }; </script> In this case an ASMX AJAX service is called to retrieve the stock quotes. The service returns an array of quote objects. The result is returned as an object with the .d property (in Microsoft service style) that returns the actual array of quotes. The template is applied with: var jEl = $("#stockTemplate").tmpl(quotes); which selects the template script tag and uses the .tmpl() function to apply the data to it. The result is a jQuery matched set of elements that can then be appended to the quote display element in the page. The template is merged against an array in this example. When the result is an array the template is automatically applied to each each array item. If you pass a single data item – like say a stock quote – the template works exactly the same way but is applied only once. Templates also have access to a $data item which provides the current data item and information about the tempalte that is currently executing. This makes it possible to keep context within the context of the template itself and also to pass context from a parent template to a child template which is very powerful. Templates can be evaluated by using the template selector and calling the .tmpl() function on the jQuery matched set as shown above or you can use the static $.tmpl() function to provide a template as a string. This allows you to dynamically create templates in code or – more likely – to load templates from the server via AJAX calls. In short there are options The above shows off some of the basics, but there’s much for functionality available in the template engine. Check the documentation link for more information and links to additional examples. The plug-in download also comes with a number of examples that demonstrate functionality. jQuery templates will become a native component in jQuery Core 1.5, so it’s definitely worthwhile checking out the engine today and get familiar with this interface. As much as I’m stoked about templating becoming part of the jQuery core because it’s such an integral part of many applications, there are also a couple shortcomings in the current incarnation: Lack of Error Handling Currently if you embed an expression that is invalid it’s simply not rendered. There’s no error rendered into the template nor do the various  template functions throw errors which leaves finding of bugs as a runtime exercise. I would like some mechanism – optional if possible – to be able to get error info of what is failing in a template when it’s rendered. No String Output Templates are always rendered into a jQuery matched set and there’s no way that I can see to directly render to a string. String output can be useful for debugging as well as opening up templating for creating non-HTML string output. Limited JavaScript Access Unlike John Resig’s original MicroTemplating Engine which was entirely based on JavaScript code generation these templates are limited to a few structured commands that can ‘execute’. There’s no code execution inside of script code which means you’re limited to calling expressions available in global objects or the data item passed in. This may or may not be a big deal depending on the complexity of your template logic. Error handling has been discussed quite a bit and it’s likely there will be some solution to that particualar issue by the time jQuery templates ship. The others are relatively minor issues but something to think about anyway. jQuery Data Link http://api.jquery.com/category/plugins/data-link/ jQuery Data Link provides the ability to do two-way data binding between input controls and an underlying object’s properties. The typical scenario is linking a textbox to a property of an object and have the object updated when the text in the textbox is changed and have the textbox change when the value in the object or the entire object changes. The plug-in also supports converter functions that can be applied to provide the conversion logic from string to some other value typically necessary for mapping things like textbox string input to say a number property and potentially applying additional formatting and calculations. In theory this sounds great, however in reality this plug-in has some serious usability issues. Using the plug-in you can do things like the following to bind data: person = { firstName: "rick", lastName: "strahl"}; $(document).ready( function() { // provide for two-way linking of inputs $("form").link(person); // bind to non-input elements explicitly $("#objFirst").link(person, { firstName: { name: "objFirst", convertBack: function (value, source, target) { $(target).text(value); } } }); $("#objLast").link(person, { lastName: { name: "objLast", convertBack: function (value, source, target) { $(target).text(value); } } }); }); This code hooks up two-way linking between a couple of textboxes on the page and the person object. The first line in the .ready() handler provides mapping of object to form field with the same field names as properties on the object. Note that .link() does NOT bind items into the textboxes when you call .link() – changes are mapped only when values change and you move out of the field. Strike one. The two following commands allow manual binding of values to specific DOM elements which is effectively a one-way bind. You specify the object and a then an explicit mapping where name is an ID in the document. The converter is required to explicitly assign the value to the element. Strike two. You can also detect changes to the underlying object and cause updates to the input elements bound. Unfortunately the syntax to do this is not very natural as you have to rely on the jQuery data object. To update an object’s properties and get change notification looks like this: function updateFirstName() { $(person).data("firstName", person.firstName + " (code updated)"); } This works fine in causing any linked fields to be updated. In the bindings above both the firstName input field and objFirst DOM element gets updated. But the syntax requires you to use a jQuery .data() call for each property change to ensure that the changes are tracked properly. Really? Sure you’re binding through multiple layers of abstraction now but how is that better than just manually assigning values? The code savings (if any) are going to be minimal. As much as I would like to have a WPF/Silverlight/Observable-like binding mechanism in client script, this plug-in doesn’t help much towards that goal in its current incarnation. While you can bind values, the ‘binder’ is too limited to be really useful. If initial values can’t be assigned from the mappings you’re going to end up duplicating work loading the data using some other mechanism. There’s no easy way to re-bind data with a different object altogether since updates trigger only through the .data members. Finally, any non-input elements have to be bound via code that’s fairly verbose and frankly may be more voluminous than what you might write by hand for manual binding and unbinding. Two way binding can be very useful but it has to be easy and most importantly natural. If it’s more work to hook up a binding than writing a couple of lines to do binding/unbinding this sort of thing helps very little in most scenarios. In talking to some of the developers the feature set for Data Link is not complete and they are still soliciting input for features and functionality. If you have ideas on how you want this feature to be more useful get involved and post your recommendations. As it stands, it looks to me like this component needs a lot of love to become useful. For this component to really provide value, bindings need to be able to be refreshed easily and work at the object level, not just the property level. It seems to me we would be much better served by a model binder object that can perform these binding/unbinding tasks in bulk rather than a tool where each link has to be mapped first. I also find the choice of creating a jQuery plug-in questionable – it seems a standalone object – albeit one that relies on the jQuery library – would provide a more intuitive interface than the current forcing of options onto a plug-in style interface. Out of the three Microsoft created components this is by far the least useful and least polished implementation at this point. jQuery Globalization http://github.com/jquery/jquery-global Globalization in JavaScript applications often gets short shrift and part of the reason for this is that natively in JavaScript there’s little support for formatting and parsing of numbers and dates. There are a number of JavaScript libraries out there that provide some support for globalization, but most are limited to a particular portion of globalization. As .NET developers we’re fairly spoiled by the richness of APIs provided in the framework and when dealing with client development one really notices the lack of these features. While you may not necessarily need to localize your application the globalization plug-in also helps with some basic tasks for non-localized applications: Dealing with formatting and parsing of dates and time values. Dates in particular are problematic in JavaScript as there are no formatters whatsoever except the .toString() method which outputs a verbose and next to useless long string. With the globalization plug-in you get a good chunk of the formatting and parsing functionality that the .NET framework provides on the server. You can write code like the following for example to format numbers and dates: var date = new Date(); var output = $.format(date, "MMM. dd, yy") + "\r\n" + $.format(date, "d") + "\r\n" + // 10/25/2010 $.format(1222.32213, "N2") + "\r\n" + $.format(1222.33, "c") + "\r\n"; alert(output); This becomes even more useful if you combine it with templates which can also include any JavaScript expressions. Assuming the globalization plug-in is loaded you can create template expressions that use the $.format function. Here’s the template I used earlier for the stock quote again with a couple of formats applied: <script id="stockTemplate" type="text/x-jquery-tmpl"> <div id="divStockQuote" class="errordisplay" style="width: 500px;"> <div class="label">Company:</div><div><b>${Company}(${Symbol})</b></div> <div class="label">Last Price:</div> <div>${$.format(LastPrice,"N2")}</div> <div class="label">Net Change:</div><div> {{if NetChange > 0}} <b style="color:green" >${NetChange}</b> {{else}} <b style="color:red" >${NetChange}</b> {{/if}} </div> <div class="label">Last Update:</div> <div>${$.format(LastQuoteTime,"MMM dd, yyyy")}</div> </div> </script> There are also parsing methods that can parse dates and numbers from strings into numbers easily: alert($.parseDate("25.10.2010")); alert($.parseInt("12.222")); // de-DE uses . for thousands separators As you can see culture specific options are taken into account when parsing. The globalization plugin provides rich support for a variety of locales: Get a list of all available cultures Query cultures for culture items (like currency symbol, separators etc.) Localized string names for all calendar related items (days of week, months) Generated off of .NET’s supported locales In short you get much of the same functionality that you already might be using in .NET on the server side. The plugin includes a huge number of locales and an Globalization.all.min.js file that contains the text defaults for each of these locales as well as small locale specific script files that define each of the locale specific settings. It’s highly recommended that you NOT use the huge globalization file that includes all locales, but rather add script references to only those languages you explicitly care about. Overall this plug-in is a welcome helper. Even if you use it with a single locale (like en-US) and do no other localization, you’ll gain solid support for number and date formatting which is a vital feature of many applications. Changes for Microsoft It’s good to see Microsoft coming out of its shell and away from the ‘not-built-here’ mentality that has been so pervasive in the past. It’s especially good to see it applied to jQuery – a technology that has stood in drastic contrast to Microsoft’s own internal efforts in terms of design, usage model and… popularity. It’s great to see that Microsoft is paying attention to what customers prefer to use and supporting the customer sentiment – even if it meant drastically changing course of policy and moving into a more open and sharing environment in the process. The additional jQuery support that has been introduced in the last two years certainly has made lives easier for many developers on the ASP.NET platform. It’s also nice to see Microsoft submitting proposals through the standard jQuery process of plug-ins and getting accepted for various very useful projects. Certainly the jQuery Templates plug-in is going to be very useful to many especially since it will be baked into the jQuery core in jQuery 1.5. I hope we see more of this type of involvement from Microsoft in the future. Kudos!© Rick Strahl, West Wind Technologies, 2005-2010Posted in jQuery  ASP.NET  

    Read the article

< Previous Page | 78 79 80 81 82 83 84 85 86 87 88 89  | Next Page >