Tag | Javascript Posts

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 ...
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 ...
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 ...
MOSS doesn't offer this out the box and of course many people would like to have it. Here's a quick and dirty javascript change which will offer this functionality. You'll have to forgive any inelegance in my coding, I'm a bit rusty ;) You need to edit the search.js file and add the following: A trim function function trim(s) { var l=0; var r=s.length -1; while(l < s.length && s.substr(l,1) == ' ') { l++; } while(r > l && s.substr(r,1) == ' ') { r-=1; } return s.substring(l, ...
Lets quickly have a look at how you can limit the entry to textbox and display the character input left to be keyed in. First things first, the script. <script type="text/javascript"> $(function() { var limit = 250; $('#dvLimit').text('250 characters left'); $('textarea[id$=txtDemoLimi... { var len = $(this).val().length; if (len > limit) { this.value = this.value.substring(0, limit); } $("#dvLimit").text(limit - len + " characters left"); }); }); </script> The $() ...
Was doing my daily research today and learned a couple of new and interesting things. A while back, I wrote a post about rendering options using .NET 3.5 SP1's charting component. I outlined a few of the more conventional/out-of-the-box methods (temporary directory, binary streaming). I also outlined a lesser-known technique in which you stream binary data to the src attribute of your <img> tag. That ends up looking like this... <img src='data:image/png;base64, iVBORw0KGgoAAAA[snip]; /> ...
c# 4.0 Part 1 The following are some of the new features and few interesting things you can do with c# 4.0. - Named and Optional Parameters - ExpandoObject - Interface with Python (and example) Program 1 class Program { // Optional parameters should be at the end static void PrintMessage(string name = "World", string greeting = "Hello") { Console.WriteLine("{0} {1}", greeting, name); } static void Main (string[] args) { PrintMessage("World", "Hello"); // prints "Hello World" PrintMessage(greeting:"Good... ...
Welcome back. This time we will look at creating a simple jquery pager plugin to use with asp.net mvc project. Please note the intent is to learn the basics of jquery plugin development. The control as such is not recommended for use in production environment. I recommend having a look at the jQuery Authoring Guideline at docs.jquery.com/Plugins/Aut... Let's begin our journey into the mystery of jquery plugin. The first step is to create a self executing anonymous function. Anonymous functions ...
Javascript does not have classes in the traditional sense, but we can achieve something similar in a number of ways. C# and Ruby both have standard class syntax. This post is part of a series comparing the language features of the C#, Javascript and Ruby programming languages. Part 1: Installation and hello world Part 2: Variables Part 3: Classes C# public class Vehicle { protected string Make { get; private set; } protected string Model { get; private set; } public Vehicle(string make, string model) ...
Let's try a simple in-place edit with jquery. For demonstration purpose I am using the plain old HTML file. However, if you, wish you could apply the same technique to asp.net, asp.net mvc or php or any other web application as well. Here is the html that we will be using for the demo. <body> <div style="line-height:3xm;back... Double Click the below paragraph to edit. </div> </br></br> <div class="edit"> Lorem ipsum dolor sit amet, consectetur ...
This edition of blog tip shows you how to focus a text input on a page to the desired element. Use jsbin.com for executing/troubleshooting or just for learning jquery or any other popular js framework that it supports. I'll show two ways to do this based on the scenarios you encounter. Using jQuery $(selector).focus method when the DOM is ready: // When the HTML DOM is ready $(function() { $("#elementId").focus(); }); The above works in most cases but may be annoying in situations you have a slow ...
This post is a follow-up on my series about validating business objects throughout different layers of a software system - domain, persistence, and (ASP.NET MVC) GUI. It demonstrates how a self-written validation can be incorporated into a web page (using a bit of JavaScript) and how this can be mapped to a custom validation on the domain side. A short recap In the first part of the above mentioned series, we developed a simple, custom validation aspect that checks if a value really is a member of ...
One of the members in the forum (forums.asp.net) is asking how to limit the number of selected items in the ListBox and so contributors (including me) gave the OP (Original Poster) different ideas on how to validate it. Some of them provided solution using pure JavaScripts and a mixture of code behind and JavaScript. However the OP doesn’t want to use JavaScript validation for some reason, so I decided to post the solution that I have provided on that thread as a reference to others. Here it is: ...
For those of you who missed the chat today, here is the raw transcript. By raw, I mean that I copied and pasted the discussion without any edits. This is divided into two parts, the top part is the answers from the Microsoft Experts and the bottom part is the questions from the audience. Answers from Microsoft: msft_davbo (Moderator): Our chat today covers the topic of Windows Embedded CE! 1. This chat will last for one hour. During this hour, our Experts will respond to as many questions as they ...
This post is part of a series comparing the language features of the C#, Javascript and Ruby programming languages. Part 1: Installation and hello world Part 2: Variables Part 3: Classes Variables C# requires that variables be declared with a specific type. Javascript and Ruby determine the type of variables at runtime. Here is the syntax: C# public string publicMessage = "Hello World"; private string privateMessage = "Hello World"; static string PRIVATE_MESSAGE = "Hello World"; Javascript var message ...
I’m going to be looking at a few different languages and blogging my thoughts. I am not a language dork so it will probably be mostly wrong. The languages I care about are c# (which is what I mostly use), javascript (which I love) and ruby (which everyone else loves). This post is part of a series comparing the language features of the C#, Javascript and Ruby programming languages. Part 1: Installation and hello world Part 2: Variables Part 3: Classes Installation C# is installed by installing visual ...
This series of posts discusses the use of an Aspect-oriented programming approach for implementing the validation part of a business domain, using the ValidationAspects aspect library, that sits on top of the PostSharp aspect weaver and allows for placing Design by Contract - style attributes on properties and method arguments, as well as for easy runtime validation of an object's state. This is the third post of a three-part series that discusses the use of these validation aspects throughout the ...
I own a company, Tiger Computer Services Ltd, which is an Independent Software Vendor (ISV) providing .NET software solutions to clients in the London area. One of the most significant considerations when running a small ISV is the cost of supporting software in the field. For some clients, support is not a billable item, especially if the fault is within the software we have provided. This means that every time the telephone rings, we bleed money, and if we have to actually go on site to resolve ...
Let's face it, it needed a rename. Mitch.Web just lacks everything in terms of marketing, so I've re-branded my (currently error logging :P) framework to "The Evil Little Developer's Toolbox" in game with my EvilDev theme. I've also made advancements (not guaranteed to work yet) on my error logging framework, mostly in terms of a new Services Project, and the Logging Service. The logging service, is a WCF Service, designed to log errors to a database. The idea behind it, well, I generally focus my ...
Silverlight has come to an age from WPF/E days and today 4.0 version was launched. Features includes: Support for enterprise applications: Printing support: Silverlight application can print itself, how the content is formatted when printed, and determine the content that will appear. It even has capabilities to print a portion of the Silverlight content. RichTextArea control / WebBrowser Control: The RichTextArea has Bi-Di support, allows hyperlinks, XAML content, and embedding of images. It also ...
A new system programming language was recently released by Google and it goes by the name of "Go". According to Google, Go is still in experimental stage and it is an attempt to combine the ease of programming of an interpreted, dynamically typed language (such as Python and javascript) with the efficiency and safety of a statically typed, compiled language like C++. Go is mostly in the C family (basic syntax), with significant input from the Pascal/Modula/Oberon family (declarations, packages), ...
http://dotnetradio.com/arch... Andrew sits down with Atif Aziz. Atif Aziz is a senior IT business analyst at Cargill International and an ex-Microsoftie. His primary focus is helping customers move to the .NET Framework. He speaks regularly at Microsoft conferences and can be reached through his web site. You can find out more about Atif Aziz by visiting his web site www.raboof.com. Raboof.com = FooBar!! Atif describes to us what ELMAH is and the history behind it. He then ...
Google has open sourced their internal JavaScript library under the name Closure. You can download the library using any svn client by pointing to http://closure-library.goog... and getting everything locally into a closure-library-read-only folder. All your custom html/js can then reside next to this folder. To use the framework you have to load the base.js into your document. <script src="closure-library-read-o... Additionally you can import specific ...
I've been very frustrated with the lack of flexibility with wordpress.com hosted blogs, so I am yet again moving. This time I wanted to host my own instance of Subtext but discovered that geekswithblogs.net uses Subtext and figured I would give one last attempt to a hosted community online :) I guess I just don't want to deal with running my own server just for a blog. The most important thing I wanted back was Syntaxhighlighter which was about impossible to use with wordpress.com without paying ...
A great VIDEO series on all the nice effects (and functionality) you can achieve with jQuery JavaScript library for those who know NOTHING about it. jQuery is a very powerful library. One of the first things I do when creating new project is to include the library in it. Microsoft is going to include it by default in ASP.NET web projects (All ASP.Net projects, not just MVC) starting Visual Studio 2010. Here are some few examples of what you can do with it (VIDEO): http://net.tutsplus.com/art... ...
Before I start to explain the topic of this post I should confess one of my many defects: I'm very lazy. Someone may have noticed that from the update rate of this blog, but I really like to avoid as much work as I can. I also really like to experiment new technologies and embedded devices, and that's bad for a lazy guy because that means having to write some code... While experimenting with Silverlight for Windows Embedded I found myself trying to write some more complex samples to continue my own ...
Microsoft has released a new Facebook SDK Version 3.0 (other than their old not-so-great one) and it looks to have not just updated APIs but also wide range of features supported in many application types. Quoting a related blog post from c|net “The web services report” blog: http://news.cnet.com/8301-1... Microsoft on Monday released a software development kit for Facebook that allows developers to create Facebook applications for Silverlight and Windows Presentation Foundation. ...
I thought twice before actually posting this. It was mostly because, of a guilt, that I might be recommending a wrong way of doing things. But then I did realize, that, even if it seems to wrong, it does provide some benefits. Anything that is beneficial, is not necessarily wrong. The problem at hand is, we want to enable ASMX style Authentication in WCF. Its not that WCF does not do a good job when it comes to Security, but because people are more inclined to send the credentials in clear text. ...
This tutorial is based on a short demo/talk I gave at the Columbus .NET Developers Group (CONDG) on IronRuby. It’s mostly designed for the .NET professional and making no assumptions of prior Ruby experience. In Part 1 we get everything installed. In Part 2 we take IronRuby for a test drive In Part 3 we use it to integrate with Cucumber. Installing IronRuby Before we get started, my instructions are more or less the same as this: http://wiki.github.com/asla... … but ...
I am currently studying some of the listed articles which may be of useful for you guys Study material on Object Persistence (This is in Java but subject is general) New things in .Net 4 Beta 2 Javascript Class browser Making jQuery calls to WCF/ASMX with a ServiceProxy Client Disable button during postback Hope they will be of great use. Thanks, Thanigainathan.S ...
This is part 2 of my series on the jQuery UI Dialog. Part 1 – The Default Dialog covered the most basic usage of the dialog widget. In this second part I will demonstrate a simple modal dialog. A modal dialog is a dialog that takes focus, and disables the rest of the application until it is closed. They are used to force the user to acknowledge something, or to gather some input. It is worth pointing out that modal dialogs can be annoying for users so you should consider carefully if it is absolutely ...
Today I was trying to call ASP.Net web service from JQuery. I thought it was easy first. But when tried implementing them I felt the difficulty. I don't had this problem while calling Ajax enabled WCF service from JQuery. Hence I did a small Bing and found out some useful tips to share. I referred links below. http://www.mikesdotnetting.... http://www.dotnetcurry.com/... http://encosia.com/2008/03/... ...
[Source: http://geekswithblogs.net/E... We had a fiddly issue with date validation in an ASP.NET MVC page failing for a valid date in Chrome, but passing in Firefox, IE etc. Tracing through our own code and xVal, the issue was narrowed down to the jQuery validation plugin (jquery.validate.js). For simple date validation, the library instantiates a date object from the given text value and lets JavaScript raise errors for invalid dates: date: function(value, element) { return this.optional(element) ...