Tag | Javascript Posts

Sinatra is a Ruby DSL for building web applications. It is distinguished from its peers by its minimalism. Here is hello world in Sinatra: require 'rubygems' require 'sinatra' get '/hi' do "Hello World!" end A haml view is rendered by: def '/' haml :name_of_your_view end Haml is also new to me. It is a ruby-based view engine that uses significant white space to avoid having to close tags. A hello world web page in haml might look like: %html %head %title Hello World %body %div Hello World You see ...
Hace algunos días, jugando con las configuraciones del IIS, revolvíamos las opciones de compresión de contenidos. La intención era habilitar gzip para el contenido estático pero la cosa salió tan mal que el portal, en vez de reducir su tamaño por los contenidos comprimidos, lo "redujo" porque el servidor dejó de enviar los archivos javascript y las hojas de estilo al navegador. Después de estar buscando como hora y media, resultó que la explicación y la solución eran bastante sencillas (y ni siquiera ...
After deciding I wanted to dive full-on into the world of ASP.NET MVC 2, I began doing some research into what would be the best way to support some of my required AJAX functionality on this platform. The result of these efforts was a barrage of options – many of which required completely different JScript infrastructure than what I planned to go forward with. As I’ve been delighted with jQuery so far, I began tossing out all approaches that didn’t natively leverage it… Thus, I planned to resist ...
InvalidOperationException: Cross-thread operation not valid: Control 'progressBar' accessed from a thread other than the thread it was created ... Now this is not a nice way to start a day! not even if it's a Monday! So you have seen this and already thought, come on, this is an old one, just ask whether InvokeRequired before calling the method in the control, something like this: if (progressBar.InvokeRequired) { progressBar.Invoke ( new MethodInvoker( delegate { progressBar.Value = 50; }) ) }else ...
Continuing on my series of builders for C# and Ruby here is the solution in Javascript. This is probably the implementation with which I am least happy. There are several parts that did not seem to fit the language. This time around I didn’t bother with a testing framework, I just append some values to the page with jQuery. Here is the test code: var initialiseBuilder = function() { var builder = builderConstructor(); builder.configure({ 'Person': function() { return {name: 'Liam', age: 26}}, 'Property': ...
Sorry for the rather lengthy post here. I get asked this all the time so I decided to post it…Visual Studio 2010 editions will be available on April 12, 2010. Product Features Professional with MSDN Essentials Professional with MSDN Premium with MSDN Ultimate with MSDN Test Professional with MSDN Debugging and Diagnostics IntelliTrace (Historical Debugger) Static Code Analysis Code Metrics Profiling Debugger Testing Tools Unit Testing Code Coverage Test Impact Analysis Coded UI Test Web Performance ...
When writing tests, other than end-to-end integration tests, we often need to construct test data objects. Of course this can be done using the class’s constructor and manually configuring the object, but to get many objects into a valid state soon becomes a large percentage of the testing effort. After many years of painstakingly creating builders for each of my domain objects I have finally become lazy enough to bother to write a generic, reusable builder class for .NET. To use it you instantiate ...
Please find how we call JavaScript Object Notation in cloud applications. As we all know how client script is useful in web applications in terms of performance. Same we can use JQuery in Asp.net using Cloud computing which will asynchronously pull any messages out of the table(cloud storage) and display them in the browser by invoking a method on a controller that returns JavaScript Object Notation (JSON) in a well-known shape. Syntax : Suppose we want to write a JQuery function which return some ...
Employee Info Starter Kit is a ASP.NET based web application, which includes very simple user requirements, where we can create, read, update and delete (crud) the employee info of a company. Based on just a database table, it explores and solves most of the major problems in web development architectural space. This open source starter kit extensively uses major features available in latest Visual Studio, ASP.NET and Sql Server to make robust, scalable, secured and maintainable web applications ...
MIX day 1’s keynote was all about Windows Phone 7 (WP7). MIX day 2’s was a reminder that Microsoft has much more going on than a new mobile platform. Steven Sinofsky, Scott Guthrie, Doug Purdy and others showed us lots of other good things coming from Microsoft, mostly in the developer stack, that we certainly shouldn’t overlook. These included the forthcoming IE9, its new JavaScript compiling engine and support for HTML 5 that takes full advantage of the local PC resources, including the Graphics ...
Well, day 2 of the MIX10 conference did not disappoint. The keynote speakers introduced the preview release of IE9, which looks really cool and quick, and Visual Studio 2010 RC that is scheduled to RTM on April 12th. It seemed to have a lot of improvements aimed at making developers more productive. Here are the current links to these two offerings: Internet Explorer 9 – Platform Preview Visual Studio 2010 and .NET 4 – Release Candidate While both of these were interesting, the demos that really ...
This post is specific to India Its been a month since I wrote my last post. Much of work has been happening around planning for Tech Ed India, the upcoming Virtual TechDays this week as well as our Developer content at the Great Indian Developer Summit 2010. Its going to be one exciting period starting this week and I am glad I would be able to meet a lot of folks who have written to me personally that they would like to catch up at Tech Ed India. For now, I had a chance to meet the Microsoft India ...
This is a message I posted to the software craftsmanship group, looking for a week-long, pairing / skill sharing opportunity in the USA. I am a journeyman software craftsman, currenlty living and working in Brisbane Australia. In April I am going to travel to the US to attend Alt.Net Seattle and Seattle codecamp. In between the two conferences I have five days in which I would like to undertake a craftsmanship mini-apprenticeship, pairing and skill sharing with your company. I do not require any ...
In the previous post I mentioned about manipulating SharePoint PeoplePicker control using JavaScript, in this post I will show how to validate the InputFormTextBox contol using custom JavaScript function. Here is the nice post by Becky Isserman on why not to use RequiredFieldValdator or InputFormRequiredFieldValid... with InputFormTextbox. function ValidateComments() { //retrieve the text from rich text editor. var text = RTE_GetRichEditTextOnly("&l... rteComments.ClientID %>"); if (text != ...
The following code adds a method to javascript arrays that returns a distinct list of values. Array.prototype.distinct = function() { var derivedArray = []; for (var i = 0; i < this.length; i += 1) { if (!derivedArray.contains(thi... { derivedArray.push(this[i]) } } return derivedArray; }; and to demonstrate: alert([1,1,1,2,2,22,3,4,5,6... This produces 1,2,22,3,4,5,6,7 ...
I was developing custom ASP.NET page for a SharePoint project, and the page uses SharePoint PeoplePicker control. I needed to manipulate the control on the client side based on the user inputs. PeoplePicker Picker is a complex control and the difficult bit is that it contains many controls on the page (use the page source viewer to see the HTML tags generated). So getting into the right bit is tricky and also the default JavaScript functions like, control.disabled; control.focus(); will not work ...
This javascript adds a method to javascript arrays that returns a boolean indicating if the supplied object is an element of the array Array.prototype.contains = function(item) { for (var i = 0; i < this.length; i += 1) { if (this[i] === item) { return true; } } return false; }; To test alert([1,1,1,2,2,22,3,4,5,6... // true alert([1,1,1,2,2,22,3,4,5,6... // false ...
Javascript allows you to declare variables simply by assigning a value to an identify, in the same style as ruby: myVar = "some text"; Good javascript developers know that this is a bad idea because undeclared variables are assigned to the global object, usually window, making myVar globally visible. So the above code is equivalent to: window.myVar = "some text"; What I did not realise is that this applies to for loop initialisation as well. for (i = 0; i < myArray.length; i += 1) { } // is equivalent ...
So I was playing around with NavigationNodeCollection, which is basically like SPNavigationNodeCollection just to make sure it worked without a hitch…Here is a little sample snippet of what should work: Unfortunately, you get a nice little javascript error that does not allow you to access the child nodes. I tried a foreach() loop that gets a NavigationNode for each parent then loops through the NavigationNode.Children that did not work either. I threw in two ExecuteQueryAsync statements thinking ...
1) Turn off Tracing unless until required Tracing is one of the wonderful features which enable us to track the application's trace and the sequences. However, again it is useful only for developers and you can set this to "false" unless you require to monitor the trace logging. How it affects performance: Enabling tracing adds performance overhead and might expose private information, so it should be enabled only while an application is being actively analyzed. Solution: When not needed, tracing ...
Why Use Client-side Javascript Templates? When building rich internet applications you often need to construct html on the client. I am going to demonstrate how to construct DOM elements using the jqote jQuery plugin (2.0.0). The naive approach to client-side html generation is to embed html inside javascript like: var text = 'Some text'; $('body').append($('<div id="content>' + text + '</div>"')); This approach fails as the complexity of the html increases. It is also a clear separation ...
Here are steps on setting up a slideshow on your SharePoint site really fast using a Content Editor WebPart (CEWP), jQuery and a Picture Library. The jQuery for the slide show makes use of the Cycle plug-in located at http://jquery.malsup.com/cy... There are plenty of demos on the site along with instructions on using the API. Here are the steps to implement the slideshow on a SharePoint site: Download the jQuery library and the Cycle plug-in and upload them to a document library Create a picture ...
UPDATE (2011-01-28): ASP.NET MVC 3 I have a newer blog post that shows how to get Client Side Validation Summary without doing any of this. I will still be answering questions and supporting this for developers who are still using ASP.NET MVC 2. If you are on ASP.NET MVC 3, go here. Problem The MicrosoftMvcJQueryValidatio... script file, which integrates with the jQuery Validation Plugin, does NOT populate validation errors inside the Validation Summary control. I will show you how to populate validation ...
Here’s the scenario: I have a form which contains a textbox. This textbox should be populated with a query string value. Users should not be able to edit the value of the textbox while adding the item. Solution: The above can be achieved using a Content Editor Web Part (CEWP) and jQuery. Steps: 1. Append the NewForm.aspx url with the following: &PageView=Shared&To... 2. This will cause the ‘Add Web Part’ tool pane to show up. 3. Add a CEWP to the page. 4. Go the webparts properties ...
Recently I was working on a project that had a large amount of roles that were going to be utilized on many different controllers and even on individual controller actions. Originally it was given to me utilizing the standard out-of-the-box way of Authorizing with MVC 1.0: //MVC’s standard authorize attribute [Authorize(Roles=”Administr... User”)] public class HomeController : BaseController { ... } I was told that role changes may occur in the future. This caused fear of the amount of work that ...
If you need to use JavaScript to do a Check All on all the checkboxes in the column, be sure to use this guy's code: http://www.highoncoding.com... If your code simply change the state (...checked == true), it does not get registered and does not get passed into the code behind. Instead, follow AzamSharp's article and make sure you initiate a click() event ...
I needed to create a web page that let the user assign one item of a grid to a target by dragging the item and dropping it on a row on a different grid. I immediately thought about using JQuery UI draggables and droppables but it didn’t work as expected. After looking for a solution for some time I finally came to this post by David Petersen explaining how to provide a helper element to JQuery to wrap the floating row while dragging and it worked perfectly. source.draggable({ helper: function(event) ...
While my home development computer is fried I’m going to hack away at my backlog of non-code related posts. Today I’d like to discuss some of the advantages and disadvantages of using Microsoft MVC over WebForms. First of all, MVC is not the end all, magical platform that many people would like you to believe. In fact I wouldn’t even recommend it to beginner developers. However, if you have experience with .NET and you’re willing to put in the time to learn how MVC works, you will find that it offers ...
So you want to read a string (say, from a file or just passed in as a variable) into a .NET class. Here's a quick example of how to do this. Let's start with our sample JSON: {"FirstName":"Joe","LastNam... So to keep this simple, let's say we want to populate a class with this data. our class: public class Person { private string _FirstName; private string _LastName; private string _MiddleName; public string FirstName { get { return this._FirstName; } set { this._FirstName= ...

A couple of people have asked me recently where the whitepaper is... its here:

http://go.microsoft.com/fwlink/?LinkId=183500

One of the great new features in Visual Studio 2010 is the ability to now use code snippets inside of ASP.NET, HTML, and JavaScript files. Snippets have long been a productivity boost for regular C# code but have been sorely missing for mark up. In fact, frameworks like MVC 2 actually ship with their own snippets. There are only about 10-15 snippets that are currently shipping with MVC (and many of those are just duplicated because there are both VB and C# versions). That doesn’t seem like very many. ...
Browser compatibility can create plenty of headaches. IE Tester DebugBar free web browser that allows you to have the rendering and JavaScript engines of IE8 beta 2, IE7 IE 6 and IE5.5 on Vista and XP, as well as the installed IE in the same process. URL: http://www.my-debugbar.com/... ...
Whenever I am working on a project that requires client-side coding, I immediately starting thinking in JQuery. There are other javascript frameworks out there, but so far I haven’t found one that allowed me to structure my client-side applications quite as cleanly as JQuery does. The only thing JQuery doesn’t support out-of-the-box is a decent templating system for emitting DOM elements. Typically you’d wind up building up large strings and passing them to a method like append, html, etc in order ...
One of the cool new features of MVC 2 is the ability to automatically pick an editor template based on the meta data of each property. This meta data can be as simple as the data type of the property itself. Take an example where we have a Contact object that has a DateTime? property for DateOfBirth. 1: public partial class Contact 2: { 3: [DisplayName("First Name")] 4: public string FirstName { get; set; } 5: 6: [DisplayName("Last Name")] 7: public string LastName { get; set; } 8: 9: [DisplayName("Date ...
More precisely, users will do things to your application that you never expected or intended. But for the most part these users are not evil. There are, though, a small subset of users who are actively attempting to corrupt your Web application and they will more likely than not find a way to do so. A blog over at SANS points this out: Client Side Input Validation is Evil. Again the title overstates the problem, but if your application relies ONLY on JavaScript validation (AJAX or otherwise) your ...
How many times have you been filling out an online form and halfway through filling in your responses you accidentally press the Enter key which then attempts to submit the form? This can be a common problem when the online form is wired up to have a "submit” button be the default form button on a page. The most complete solution to this issue is having your submit process be able to handle all scenarios of submission (incomplete, invalid, etc). If you are looking for a quick (partial) fix though, ...
Technorati Tags: ASP.NET,TreeView,jQuery When we expand TreeView node JavaScript function TreeView_ToggleNode gets executed (it’s part of the TreeView control itself). So we will “override” this function and add our own functionality to perform scroll to the expanded node. To find source code of TreeView_ToggleNode function you can use IE Developer Toolbar or Firebug. I removed some code from this function that I don’t need to make it shorter. Here is the result. Everything should be pretty self ...
Technorati Tags: ASP.NET,TreeView,jQuery If we have TreeView inside of the div with the fixed width and height we want selected node to be visible after postback. Here is small JavaScript function that does this (you don’t have to use jQuery as I did to get the result): 1: function ScrollToSelectedNode() 2: { 3: //* get selected node id 4: //* 'tvwScrollTo' - is our tree view id 5: var selectedNodeID = $('#<%=tvwScrollTo.ClientID %>_SelectedNode').val(); 6: 7: if (selectedNodeID != '') 8: { ...
Technorati Tags: TreeView,ASP.NET,JavaScript TreeViewClientID_Data.selec... where TreeViewClientID_Data is the name of the TreeView javascript object that has “selectedNodeID” property. We can easily load this object and get selected node id like this: 1: Sys.WebForms.PageRequestMan... 2: 3: function EndLoadedHandler(sender, args) 4: { 5: //* make sure that object is fully loaded 6: var data = eval('<%=tvwScrollTo.Cli... %>_Data'); ...
jQuery 1.4 released. You can find more info at http://api.jquery.com/categ... Also celebrate jQuery 1.4 release with 14 days of jquery at jquery14.com/pre-release-1 Learn about 15 new features of jQuery you must know net.tutsplus.com/tutorials/... Enjoy jQuerying ...
Hey there everyone. I was recently tasked to pitch a book to my publisher. As a first step I need to come up with an outline for the Table of Contents. This book is the standard cookbook style with an added focus on the MVC side of ASP.NET. I have been poking about at other similarly styled books to get some ideas. I think comparing ASP.NET Web Forms to ASP.NET MVC would provide some folks with a good reference point when looking at the two ways of doing things. (Thanks to my friend James Shaw for ...
I have a Model popup from ajax control toolkit in my page.that point to a asp:panel that will going to show a close button in the top left corner. When using with update panel and lots of ajax stuff ended up getting the following javascript error in IE only , it worked perfectly in firefox Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method i searched alot on the internet for the solution, solution was there that suggest just move the button outside ...
After my last post about goals for 2010 when I realized it has been over 6 months since I started blogging, I began to think about my blogging process and how it has changed over that time. I’ve made quite a few changes and upgrades to various portions of my blogging process over that time. Here’s a quick overview of where I’m at now as well as some tips for those of you thinking about starting up a blog but not knowing where to start. Tools Live Writer – Based on various buzz from other bloggers ...
We are excited to announce that Visual WebGui 6.4 client is going to adopt jQuery as its client engine in order to provide better support for cross browsers, enhanced UI behaviors and most important provide a familiar API to write Visual WebGui extensions such as custom controls and utilizing different protocols such as JSON and REST. jQuery is a lightweight open source JavaScript library (only 15kb in size) that in a relatively short span of time has become one of the most popular libraries on the ...
I had to struggle a little with a problem in using ASP.NET TreeView, which I had customized for one of the projects. The issue was to execute some client side script, after the TreeView has completed loading Nodes asynchronously. However, as I found out - unlike other controls TreeView does not provide a ready mechanism to hook custom code after the nodes are loaded asynchronously (using PopulateOnDemand property) Problem description: When we use ASP .NET TreeView control, it provides us an option ...
I put the final touches on a small Silverlight app that I had been working on over the weekend, and was doing some final testing of it. The app is pretty simple: it just displays stuff and has some buttons that take you to other web pages, launches the local email client, or downloads documents from a website. Simple tasks. I ran into a weird issue which I’m pretty sure is Word 2010 related (not the focus of this post, more on that another time). I asked a buddy of mine to access the SL app on my ...
Technorati Tags: ASP.NET,C#,GridView Many developers from the forums (forums.asp.net) are asking if how to implement fix header in GridView while scrolling. We all know that there are lots of examples out there that provide a solution that are available, however some of the solutions provided are not cross browser compatible. While searching for a cross browser solution, I found this article at devarchive.net and it seems very interesting to me. So I play around with the extender provided by devarchive ...
EnGraph is looking for an ASP.NET developer to join our team. We are a small company in Lenexa, KS that creates .NET applications for Paratransit agencies. A good candidate would be very comfortable with ASP.NET, Forms Authentication and JavaScript. A huge bonus would be knowledge of IIS, Google Maps API, AJAXPro, ActiveReports, WPF and SQL. We are accepting resumes immediately and look to hire as soon as January 18th. We would consider contract or full-time and we would require office attendance. ...
So if you are in my situation, where you have a project using prototype and you want to use the jQuery date picker, you will notice that in certain situations, depending where your javascript is defined, you pickers won't work. The problem is the jQuery and Prototype $. You need to redefine the jQuery $ with anoter literal, like $j. So try this: <script type="text/javascript" charset="utf-8"> var $j = jQuery.noConflict(); $j(function() { $j('.date-pick') .datePicker({ createButton: false }) ...
I have been a developer for over 10 years, and at one point or another completely relied on the knowledge of someone with more experience than I had to make something work. I figure that it's time for me to start giving back. As background, I am a Microsoft technology based developer currently working in WCF/WPF/XAML, although I have only been doing this type of development for a little while now. I have a solid background that covers ASP.Net (C#/VB.Net), Traditional ASP, Javascript, custom AJAX ...