Wednesday 14 July, 2010

Magic of CSS3 - Part 2

Super Awesome Buttons with CSS3 and RGBA :




CSS3 is finally starting to see the light at the end of the tunnel as new browsers like Firefox and Safari continue to push its implementation.

One of our favorite things about CSS3 is the addition of RGBA, a color mode that adds alpha-blending to your favorite CSS properties. We've kicked the tires on it a bit with our own projects and have found that it helps streamline our CSS and makes scaling things like buttons very easy. To show you how, we've cooked up an example with some super awesome, scalable buttons.

View Tutorial : CSS3 Button

Magic of CSS3 Part I


Border-radius: create rounded corners with CSS! :


W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function, which allows you to create round corners on box-items. This is an example
These different corners can also each be handled on their own, Mozilla has other names for the feature than the spec says it should have though, as it has

Mozilla/Firefox and Safari 3 users should see a box with a rounded left upper corner.
Mozilla/Firefox and Safari 3 users should see a box with a rounded right upper corner.
Mozilla/Firefox and Safari 3 users should see a box with a rounded left lower corner.
Mozilla/Firefox and Safari 3 users should see a box with a rounded right lower corner.

These are handled by / should be handled by:

-moz-border-radius-topleft / -webkit-border-top-left-radius
-moz-border-radius-topright / -webkit-border-top-right-radius
-moz-border-radius-bottomleft / -webkit-border-bottom-left-radius
-moz-border-radius-bottomright / -webkit-border-bottom-right-radius

Thursday 8 July, 2010

How to debug your jquery code essential tools & tricks

Not only are the JavaScript alert methods annoying, but until recently developers haven't had any really good tools to help them debug client-side code when they’re trying to re-create or resolve errors. Alert methods can also result in certain false assumptions about your code. For example, an alert dialog box waits to be closed before execution proceeds, so the timing of events can be off if you use this tool as a debugging mechanism.
In this article, I’ll describe some techniques to assist  you in the debugging process when you are using jQuery in client-side Web development. Thankfully, we have much better tools and technologies than developers had even five years ago.


Ping this to get full article  : How to debug your jquery code essential tools & tricks

Excellent Tips to improve UI using CSS3 and jquery

CSS3 is getting a lot of attentions recently.  I'm absolutely in love with CSS3. Rounded corner, drop shadow and rotation couldn't be easier! The only drawback is, CSS3 standard is not fully implemented by most browsers and also, I believe you will get a lot of CSS validation errors as well. However, there are quite a lot of websites start using it already, for example, Twitter, it uses rounded border, and replace the rounded border with images if you viewed it with IE 7 or 8, and totally ignore IE6 users (*salute*, well done twitter).

And another great example with CSS3 and CSS3 animation: Neutron Creation
This post is all about CSS3 and Javascript. With all the new features that come with CSS3, there are whole lot of animation possibilites that can't be achieve before. So, Check this out and get inspired!
Excellent Tips to improve UI using CSS3 and jquery

Sunday 4 July, 2010

Exception handling in AJAX (ASP.NET)

Exception handling plays an important role in any application development. The way we present our exceptions to the user decides the quality of our software. The way we design a pattern for exception handling in C#, ASP.NET we should also design a similar pattern for implementing Ajax exceptions. If an Ajax exception is not caught, then it should as a pop-up directly on the screen showing the exact technical error message with a code. A layman/user will never know what went wrong behind the scene.








Different ways of handling exception in Ajax
1. Using the AsyncPostBackErrorMessage property of the Script Manager class
You can set the exception message that needs to be shown to the user to the AsyncPostBackErrorMessage property of the ScriptManager object. This can be achieved in the following way:







scriptManager.AsyncPostBackErrorMessage = "Oops..\nAn error occurred while processing";

Set the above exception message in the catch block of the method. When an exception occurs, this message will be shown to the user in a pop-up window.
2. Using the above method will show the exception message to the user as a pop-up window. It is not a good practice to show a pop-up on error. Better way to do is to add a Label field to the web page and set the text of that label field with the exception message. For more clarity to the user, the exception message can be shown in Red color. Ajax inherently exposes an event OnAsyncPostBackErrorHandler. This event is invoked when an exception occurs in your web page. It is better to set the exception message in this event as shown below:






protected void OnAsyncPostBackErrorHandler(object sender, AsyncPostBackErrorEventArgs e)
{
  scriptManager.AsyncPostBackErrorMessage = "Oops..\nAn error occurred while processing";
}

Is this going to suffice?
The answer it NO. Here we have just handled an event and set the required exception message to the AsyncPostBackErrorMessage property of the scriptManager class. We have to handle another event at client side to set this message to the Label control OR to some DIV as ModalPopupExtender of AjaxControlToolKit and inform the Ajax manager to not show the ugly pop-up:
The key to custom error handling in ASP.NET AJAX is the EndRequestEventArgs class, available when handling the endRequest event. It provides information on any error conditions that have resulted and exposes a method to let the framework know that we’ve handled the errors on our own.
I’m going to add a div, to serve as our replacement error message:
Next, some CSS to style the div and close button:
#Error {
  top: 0px;
  right: 0px;
  width: 125px;
  background-color: yellow;
  border: solid 1px Black;
  padding: 10px;
  font-family: Sans-Serif;
  font-size: 10pt;
  position: absolute;
  margin: 5px;
}
#CloseButton {
  float: right;
  cursor: pointer; 
}
Finally, we need to add some JavaScript to tie it all together:
Sys.Application.add_load(AppLoad);

function AppLoad()
{  
 Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequest);
}

function BeginRequest(sender, args) 
{
  // Clear the error if it's visible from a previous request.
  if ($get('Error').style.visibility == "visible")
    CloseError();
}

function EndRequest(sender, args) 
{
  // Check to see if there's an error on this request.
  if (args.get_error() != undefined)
  {
    // If there is, show the custom error.
    $get('Error').style.visibility = "visible";
    // Let the framework know that the error is handled,
    //  so it doesn't throw the JavaScript alert.
    args.set_errorHandled(true);
  }
}

function CloseError() {
  // Hide the error div.
  $get('Error').style.visibility = "hidden";
}

The crux of this method is EndRequestEventArgs.set_errorHandled(). This tells the AJAX framework to call off the dogs and prevents the JavaScript alert from being displayed. Now, clicking Button1 results in this:





We have complete control over the error display. No JavaScript alert!
source: encosia.
Happy Coding :)

Saturday 3 July, 2010

Simulate Slow Internet Connection while Testing your Apps

So you have your Next-gen cool Web 2.0 application ready! You have tested it on your LAN environment and on your high speed internet connection – all seems ok and you are ready to deploy it in the ‘real world’. A few hours later, you get feedback that your application does not perform well on slower connections. That hurts!
Well the truth is that real world internet connections are much slower than you think. Your application end users may not always be broadband users but also people accessing your app through a dial-up connection, mobile sets, 3G or USB dongles. Most designers and developers forget to test their application on slower internet connections, resulting in a poor performing application.
Now there are many tools that let you simulate slow network connections. Out of them, what caught my attention is a nice Firefox browser plug-in that ‘effortlessly’ lets you simulate different speeds of Internet connection and lets you view the effects of slow speeds on your application. The plug-in is called Firefox Throttle.
Firefox Throttle is an extension that allows you to control download/upload rates and monitor current bandwidth utilization. Amongst other features, what I liked the most was that it lets you throttle localhost connections as well. Cool! Here’s a screenshot of the plugin in action.


The plug-in shows the current bandwidth utilization indicators in its Status panel as shown below and lets you quickly turn on/off throttling.

PingBack From this : DevCurry Atricle

Wednesday 5 May, 2010

Visual jQuery for jQuery 1.3.2

Visual jQuery website, which is originally created by Yehuda Katz & updated by Remy Sharp, is very helpful & interactive to explore jQuery API. I'm using this website a lot more than jQuery documentation website

Update Version on : http://api.jquery.com/visual/

Test your jQuery code Online using jsFiddle

Pingback from Test your jQuery code Online using jsFiddle Posted by Suprotim Agarwal 



The ‘Works on My Machine’ is a common quote I often get to hear from fellow developers. When it comes to jQuery development, wouldn’t it be nice for developers to be able to see, test and edit each others code, using a common development environment. jsFiddle let’s you do that.
jsFiddle provides an online environment where you can preselect/add popular JavaScript frameworks and test your code. Here’s what the interface looks like:

















As you can see, the interface is divided into an HTML editor, CSS Editor, JavaScript Editor and Output.


Old Version - http://jsfiddle.net/ZqFp5/
New Version - http://jsfiddle.net/ZqFp5/1/
Slick, I must say!
Update: Check out Elijah’s post Tips using Firebug Lite and Full Screen with jsFiddle



Create PDF documents from .NET applications


I have seen a very common question in the forums – How can I create PDF documents from my .NET application?

Here are some of the OpenSouce and Paid libraries that allow you to do so:

Open Source
PDFSharp - PDFsharp is the Open Source library that easily creates PDF documents from any .NET language
iTextSharp – Library to create/manipulate PDF documents on-the-fly
Report.NET - generate PDF documents in a simple and flexible manner
PDFjet for .NET - royalty-free PDF library

Paid Libraries
PDF4NET - .NET library for adding PDF capabilities your .NET application
ABCpdf - Dynamically create Adobe PDF documents on the fly
DynamicPDF™ Generator for .NET - real-time creation of PDF documents based on dynamic data

Thursday 1 April, 2010

Simple tooltip apply on all Title attributes in Web App - jQuery plugin



A few weeks ago I needed to display a tooltip for all fields having title attributes in web application. There are lots of jQuery plugins for that but I just needed a simple one which display a message on mouseover.
The text displayed in tooltip is the same as the TITLE attribute of the element.Either it become set as ToolTip on web controls in aspx page or on Resource Files(.resx)




(function($)
{
    $.fn.simpletooltip = function()
    {
        return this.each(function()
        {         
            if ($(this).attr("title").length > 0)
            {
                var text = $(this).attr("title");
                $(this).attr("title", "");             
                if (text != undefined)
                {
                    $(this).hover(function(e)
                    {
                        //alert("hover");
                        var tipX = e.pageX + 12; //set acc to ur need
                        var tipY = e.pageY + 12; //set acc to ur need
                        $(this).attr("title", "");
                        $("body").append("
");
                        if ($.browser.msie)
                            var tipWidth = $("#simpleTooltip").outerWidth(true)
                        else
                            var tipWidth = $("#simpleTooltip").width()
                        $("#simpleTooltip").width(tipWidth);
                        $("#simpleTooltip").css("left", tipX).css("top", tipY).fadeIn("medium");

                    },
   function()
   {
       $("#simpleTooltip").remove();
       $(this).attr("title", text);
   });
                    $(this).mousemove(function(e)
                    {                      
                        var tipX = e.pageX + 12;
                        var tipY = e.pageY + 12;
                        var tipWidth = $("#simpleTooltip").outerWidth(true);
                        var tipHeight = $("#simpleTooltip").outerHeight(true);
                        if (tipX + tipWidth > $(window).scrollLeft() + $(window).width()) tipX = e.pageX - tipWidth;
                        if ($(window).height() + $(window).scrollTop() < tipY + tipHeight) tipY = e.pageY - tipHeight;
                        $("#simpleTooltip").css("left", tipX).css("top", tipY).fadeIn("medium");
                    });
                }
            }
        });
    }
})(jQuery);

this.hidetooltip = function()
{
    $("#simpleTooltip").remove();
    $(this).attr("title", "");
};


CSS :



#simpleTooltip 
{
 position:absolute;
    border  :1px solid #333;  
 background:#f7f5d1;
 padding:5px;
 color:#333;
 cursor:pointer;
 font-weight:bolder;
 
 display:none;
 border-radius: 4px;
 -webkit-border-radius: 4px;
 -moz-border-radius: 4px;
 }
How to use :

$("#some-element").simpletooltip()
or
$("a.some-class").simpletooltip()
or
$("input[type='button']").simpletootip()

or Set it on Ajax PageLoad() to set back on async postback using updatePanel :


 function pageLoad()
         {
              // use to hide all tooltip on Async postback in updatepanel
              hidetooltip();
             //use when to apply on those elements having tooltip Css Class
             $(".tooltip").simpletooltip();
            //use to apply on whole input type fields on Web Application
             $("input").simpletooltip();
         }


Additional Info :

Tested with IE 6+, Firefox 3, Safari 4 and Opera 9
jQuery 1.3.2 (it should work with previous releases of jQuery, but I didn't test it)

Click here to download the simpletooltip jquery plugin.


Tuesday 9 March, 2010

Master Page - Content Page - Javascript Path problem


Most of the developers who are using Master page and content pages in different folders, paths has faced a problem of reference of javascript file.

It was a nightmare and was a big headache to decide whether to use the masterfile concept or not. There are many advantages of using master pages and content pages.
We will not go in detail to find the advantage but will look to find the solution for the javascript path issue. One major advantage of using Masterpage is, if we are using single masterpages for the content pages irrespective of any path of content pages, the browser will cache the javascripts and css files, which optimizes the performance of the website.

* To show in real life we created a appllication where we saved all the javascripts in a folder
[ ApplicationName]/Common/Scripts

Created a master page at [ ApplicationName]/Common/Usercontrols
   and dragged the javascript files .

Created two content pages one at 
      >>  [ ApplicationName]/Common/Usercontrols/Test.aspx and
      >>  [ ApplicationName]/Test.aspx
   refferring to the same master page.




While testing both,  [ ApplicationName]/Test.aspx was not reffered to the javascript, same will happen if any other pages which are in other path. This is the problem 


The solution is simple:
   Instead of

< script type="text/javascript" src='../Scripts/jQuery/jquery-1.3.2.min.js'>&lt/script>
 make the reference as
< script type="text/javascript" src=''<%=ResolveUrl("../Scripts/jQuery/jquery-1.3.2.min.js")%>   </script>


as shown below.

just add "ResolveUrl" for the src of the file