January 14 marks the birth of jQuery. To celebrate the release of jQuery 1.4 (also on January 14), the jQuery team is bringing fourteen consecutive days of new releases. Each day, they will publish videos, tutorials, code releases and other fun stuff. They have already announced the re-design of the jQuery API site. For more [...]
This post explains self-executing functions and its benefits. So lets started by breaking down a normal function and converting it into one …
var myVar = “This is a normal function…”;
function ShowAlert(textToAlert)
{
alert(textToAlert);
}
ShowAlert(myVar);
We all know that functions are also objects in JavaScript. Thus they can be evaluated using the eval() function and also in the case of setInterval() function [...]
Woork author Antonia Lupetti has recently released a visual cheat sheet for jQuery 1.3. The cheat sheet having six pages is a helpful reference containing the complete API reference with descriptions and sample code.
What I like most about this cheat sheet, is it’s simple and elegant design. Kudos to Antonia!
Demo
I recently came across a very nice jQuery control library called jQuery Tools. The library features the following JavaScript tools :
Tabs
Tooltips
Expose
Overlay
Scrollable
FlashEmbed
So now you are thinking “Whats so great about this? We already have tons of jQuery plugins for this…”. I thought so too.
The striking advantage of this library is that these tools can be combined, [...]
During your development, you may notice that your code file contains using directives which are not required by your code. The Visual Studio IDE provides the Organize Usings option to remove/sort these using directives. To access this option, right-click anywhere within your code editor and select one of the sub-menu options for Organize Usings option.
Remove [...]
Like most developer I love jQuery and appreciate the intellisense support in Visual Studio. I am very particular about the format for my code and often use the Document Format option of the IDE. What I noticed was that my braces were never placed on new lines, and I wanted to change this. So here’s [...]
DBCC CHECKIDENT can reset the identity value of the table. The syntax is as follows :
DBCC CHECKIDENT (<table_name>, reseed, <seed_value>)
After executing this statement, the next inserted record will have seed_value + 1 as value. This rule is applicable only if the table previously contained records.
In case of a table with no records, since the current [...]
Here’s a small javascript helper to read Url Query String Parameters.
function GetUrlParams()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?')
+ 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
The above function, will read the url, get the query string part i.e from (”?”) and split each paramter by the (”=”) character and [...]
Unlike the normal TextBox, the MaxLength property doesnt work for MultiLine TextBox. Heres a small trick to solve the problem:
<asp:TextBox ID="txtExample" runat="server" TextMode="MultiLine" />
<asp:RegularExpressionValidator ID="revExample" runat="server"
ControlToValidate="txtExample" ValidationExpression="[\s\S]{1,200}"
Display="Dynamic" ErrorMessage="Length cannot be greater than 200 characters" />
The above markup validates the revExample TextBox / textarea and limits the max characters to 200. By modifying the regular expressions, [...]
Visual Studio is filled with nifty tricks, which if leveraged properly in the right situation can make the developers life easy. Consider if you had a looping statement, and wanted to debug it, but only for a particular value. Rather than hitting the breakpoint every time, you can shorten the hits by using a Conditional [...]
Tip to debug a running instance of an application
Although there are tons of charting / reporting plugins ranging from inline charts to flash charts, each one is unique in terms of technology, footprint or usage. I needed something compatible with jQuery and supported many as many chart types as possible. Here is the pick list:
1. jQuery Google Charting (http://www.keith-wood.name/gChart.html)
This plugin allows you to [...]
I needed to integrate support for vCalendar in my current project. So i went through the vCalendar spec 1.0 at http://www.imc.org/pdi/vcal-10.txt and wrote this class. Although I have not implemented all the specification features, but this should prove sufficient for the usual requirements. If you have any comments / suggestions , let me know.
using System;
using [...]
If you are using LINQ and have a query that looks something like this :
var myUser = (from user in dbContext.Users
join comp in dbContext.Companies on user.CompanyID equals comp.CompanyID
where user.UserID == “12345″
select new {user.UserID, user.Name, comp.Name}).SingleOrDefault();
string _userID = myUser.UserID;
string _userName = myUser.Name;
string _companyName = myUser.Name;
In the above code, example we are using a syntactic sugar feature [...]
Heres a quick tip. If you need to include a request for read receipt like Microsoft Outlook while sending mails through Asp.net, just add the Disposition-Notification-To Header to the MailMessage.
The MailMessage class does not have a corresponding attribute and thus it has to be set through the Header.
MailMessage mm = new MailMessage(fromAddress, toAddress);
mm.Subject = subject;
mm.Headers.Add("Disposition-Notification-To", [...]
In my current project I needed to access the Session state in a Generic Handler. To my dismay, i realized that the Session StateBag was null. The StateBag class is sealed and manages the Viewstate of the Asp.net server controls and pages.
Upon discussion with my colleague, Mr. Hamed, we found the solution to my problem. [...]
Recently, I felt the need for removing a project from the Visual Studio Start Page, so I Googled and would like to share the solution. Don’t forget to close visual studio before trying this out. This trick requires modification to registry, so if you are skeptical do make a backup of the registry before proceeding.
Start [...]
Being a web developer, its important we realize the threat and severity of SQL Injection. Unfortunately detecting such vulnerabilities is time-consuming and eventually we might not even be able to identify all the loop holes.
HP Security Labs provides a free tool called Scrawlr that scan your site and patches up the exploits. This great tool [...]
As a web designer, we use resources like CSS and javascript. These files should be optimized using compression for reducing the file size and hence the load time.
To decrease the file size web designers can follow 3 guidelines:
Remove whitespace like tabs, spaces, blank lines, etc.
Remove unused CSS classes and ID’s.
Use shorthand wherever applicable. For example [...]
When you pass information from one page to another, you are passing information that anybody can sniff. For example consider a scenario, in which you pass the customer id as a query string:
http://www.yourapplication.com?customer_id=15
Now if somebody replaced 15 with say 10 or any other number, they can pull up other customer information. And thats a bad [...]
If you are using Membership Provider in your ASP.net application, you might come across a scenario in which you need to have both Security Question and Answer feature and would also like to programmatically reset the password for an account.
So if you run the code
string username = “user”;
string password = “password”;
MembershipUser mu = Membership.GetUser(username);
mu.ChangePassword(mu.ResetPassword(), password);
You [...]