Html Css | Fancy Css Button | Button With Sliding Doors Technique | Dynamic Width Button | Three Sliced Background Images Button | Rounded Css Button | Backward Compatibility Button

Sliding door technique is to use images in background of the button. As far as, the browser supports html5 and css3 this technique is not required but no one can be sure of that as many users still prefer IE6 and other browsers which are not compatible for htm5 and css3.
This is what it will look like
There are ways by which one can make dynamic with buttons. Some are using 2 images whereas some are using 1 image; however, I am going to do this with 3 images. The behind this is, unlike other two, it will not disappoint you in a scenario where your button size exceeds your image size.
            <link rel="stylesheet" type="text/css" href="default.css" />
            <li class="css_li">
                <div class="css_div">
                    <a href="#" class="css_a">Search</a>
            <li class="css_li">
                <div class="css_div">
                    <a href="#" class="css_a">View</a>
            <li class="css_li">
                <div class="css_div">
                    <a href="#" class="css_a">Add New</a>
            <li class="css_li">
                <div class="css_div">
                    <a href="#" class="css_a">Edit</a>
            <li class="css_li">
                <div class="css_div">
                    <a href="#" class="css_a">Delete</a>
* {
	margin: 0; 
	padding: 0;
.css_li {
	list-style-type: none;
	background-repeat: repeat-x;
	background-image: url(img_20141109_mid.png);
	height: 58px;
	margin: auto;
	float: left;
	white-space: nowrap;
.css_a {
	display: block;
	text-decoration: none;
	background-image: url(img_20141109_rgt.png);
	background-repeat: no-repeat;
	background-position: right;
	padding-right: 28px;
	padding-left: 28px;
	line-height: 58px;
	font-size: 14px;
	color: #371C1C;
.css_div {
	background-image: url(img_20141109_lft.png);
	background-repeat: no-repeat;

ASP.Net | Parameterized Url Rewriting | Hide Page Extension in Parameterized Url | Url Rewriting with QueryString

As I mentioned in my previous blog, there are innumerous ways to enable URL rewriting feature in Asp.Net. We have also seen how we can change the ASPX page extension to some other extension.
Here in this article we would be able to see how to remove the ASPX extension completely from the URL and make it more meaningful by adding parameters to it. Let’s have a look on an example of this.
Instead of
It can be
When we imagine this kind of scenarios, we must keep in mind (1) that it should support both to an URL of a domain name and to an URL of a domain name + virtual directories. (2) that the images, javascripts and CSS files should not be blocked. (3) that it should handle URL with ASPX extension. (4) that it should handle the URL name which the user can type in lowercase, upper case and in combination of the both. (5) that the URL can contain any number of virtual directories. (6) that the page name not necessarily be the first word after the domain name. We need to handle these kinds of issues.
Let us do it. The only thing we need to do is to put the following code in the GLOBAL.ASAX file of our ASP.NET project. Yes, simply replace your APPLICATION_BEGINREQUEST event by the following code.
Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim lvRelUrl As String = Request.Path.ToLower.Trim
    If lvRelUrl.Contains(".aspx") Then
        Response.Redirect(Replace(lvRelUrl, ".aspx", ""))
    ElseIf Not lvRelUrl.Contains(".") Then
        If lvRelUrl.EndsWith("/") Then lvRelUrl = Left(lvRelUrl, Len(lvRelUrl) - 1)
        Dim lvVirDir As String = Request.ApplicationPath.ToLower.Trim
        If lvVirDir.EndsWith("/") Then lvVirDir = Left(lvVirDir, Len(lvVirDir) - 1)
        If lvRelUrl <> lvVirDir Then
            Dim lvArg As String = Replace(lvRelUrl, lvVirDir, "")
            If lvArg.StartsWith("/") Then lvArg = Right(lvArg, Len(lvArg) - 1)
            Dim laArg() As String = Split(lvArg, "/")
            lvRelUrl = lvVirDir & "/" & laArg(0) & ".aspx"
            Dim lvCtr As Integer = 0
            For lvCtr = 1 To laArg.Length - 1
                lvRelUrl = lvRelUrl & IIf(lvCtr = 1, "?", "&")
                lvRelUrl = lvRelUrl & "q" & Trim(Str(lvCtr)) & "=" & laArg(lvCtr)
        End If
    End If
End Sub
Now, to see the magic of this code, add a page DEFAULT.ASPX, if it is not already there. And replace the PAGE_LOAD event of it.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim lvTxt As String = ""
    lvTxt = lvTxt & "<br />UrlDetails:<br />" & StrDup(80, "=") & "<br />"
    lvTxt = lvTxt & "<table cellspacing=0px cellpadding=0px border=0>"
    lvTxt = lvTxt & "<tr><td>RawUrl:</td><td>" & Request.RawUrl & "</td></tr>"
    lvTxt = lvTxt & "<tr><td>AbsoluteUri:</td><td>" & Request.Url.AbsoluteUri & "</td></tr>"
    lvTxt = lvTxt & "<tr><td>OriginalString:</td><td>" & Request.Url.OriginalString & "</td></tr>"
    lvTxt = lvTxt & "<tr><td>AbsolutePath:</td><td>" & Request.Url.AbsolutePath & "</td></tr>"
    lvTxt = lvTxt & "<tr><td>Host:</td><td>" & Request.Url.Host & "</td></tr>"
    lvTxt = lvTxt & "<tr><td>Authority:</td><td>" & Request.Url.Authority & "</td></tr>"
    lvTxt = lvTxt & "<tr><td>Scheme:</td><td>" & Request.Url.Scheme & "</td></tr>"
    lvTxt = lvTxt & "<tr><td>ApplicationPath:</td><td>" & Request.ApplicationPath & "</td></tr>"
    lvTxt = lvTxt & "<tr><td>HostNameType:</td><td>" & Request.Url.HostNameType & "</td></tr>"
    lvTxt = lvTxt & "</table>"
    lvTxt = lvTxt & "<br />QueryString:<br />" & StrDup(80, "=") & "<br />"
    Dim lvCtr As Integer = 0
    For lvCtr = 0 To Request.QueryString().Count - 1
        lvTxt = lvTxt & Request.QueryString(lvCtr) & "<br />"
End Sub
And now type the URL in different ways to see the effects.
URL: localhost/nin
URL: localhost/nin/default
URL: localhost/nin/default.aspx
URL: localhost/nin/default/class/xii/section/c
URL: localhost/nin/img01.jpg

ASP.Net | Url Rewriting | Hide Page Extension in Url

Now a day it’s been a trend to give a more meaningful Url to the end user. I have been asked by one of my blog-reader to give some simple solution to hide the page name extension. Let us have a look on an example, an example of Url Rewriting can be..
Instead of
It can be
There are innumerous ways to enable this feature in Asp.Net. But I am not going to write anything on that here, rather I would talk as to what can be the simplest way of hiding the extension of an un-parameterized server page. You can call all server pages with an .htm extension or any other extension you like.
So, to call a home.aspx as home.htm or anypage.aspx as anypage.htm, all that you have to do is, to write the following code in Application_BeginRequest event of global.aspx page. Remember that if any aspx page is called with aspx extension, it will automatically be converted as htm extension. It will also do the needful for other extensions like .jpg, .png, .gif etc.
Dim vPage As String = Request.Path()

If vPage.EndsWith(".htm") Then
    vPage = Replace(vPage, ".htm", ".aspx")
ElseIf vPage.EndsWith(".aspx") Then
    vPage = Replace(vPage, ".aspx", ".htm")
End If
Samar, I hope this is what you were looking for.
I am planning another article for hiding the extension of a parameterised Url wherein you can do Query on the Strings. For example, this article will not help you if you call anypage.aspx?cat=3x as anypage.htm/3x or anypage.htm/cat/3x. Meet you soon.

VB.Net | Serial Port Communication With DataReceived Event

Before planning this article I have gone through related articles. It surprised me to know that developers are facing lot of issues with the SerialPort DataReceived event. But why so? Because this event is raised on the top of operating system event, that’s why. Hence there will naturally be a delay between your expected and actual event. So, there are issues.
You know what, whenever you do device communication, you need to understand that side device in a more sophisticated approach. And now, how to do that? That is, to accept the fact that you don’t have any control over it.
Let us see, what is the better way to ensure smooth execution of the code. Add a form to your project. Place a SerialPort control to this form. And rename this control from SerialPort1 to spObj. Now copy the following code.
Dim spDrLine As String = ""
Dim spBuffer As String = ""
Private Sub frmOne_Load( _
  ByVal sender As Object, _
  ByVal e As System.EventArgs _
  ) Handles Me.Load
   Call spOpen()
End Sub
Private Sub spOpen()
    spObj.PortName = "COM1"
    spObj.BaudRate = 9600
    spObj.Parity = IO.Ports.Parity.None
    spObj.DataBits = 8
    spObj.StopBits = IO.Ports.StopBits.One
    spObj.Handshake = IO.Ports.Handshake.RequestToSend
    spObj.DtrEnable = True 'imp
    spObj.RtsEnable = True 'imp
    spObj.NewLine = vbCr
    spObj.ReadTimeout = 250
    spObj.WriteTimeout = 250
  Catch ex As Exception
    'handle the way you want
  End Try
End Sub
Private Sub spClose()
    If spObj.IsOpen Then
    End If
  Catch ex As Exception
    'handle the way you want
  End Try
End Sub
Private Sub spObj_DataReceived( _
  ByVal sender As Object, _
  ByVal e As System.IO.Ports.SerialDataReceivedEventArgs _
  ) Handles spObj.DataReceived
    If spObj.IsOpen Then
      spDrLine = spDrLine & spObj.ReadExisting() 'imp
      If InStr(1, spDrLine, vbCr) > 0 _
        Or InStr(1, spDrLine, vbLf) > 0 Then
        spBuffer = spDrLine
        spDrLine = ""
        Me.Invoke(New EventHandler( _
        AddressOf doProcess)) 'imp
        Exit Sub
      End If
    End If
  Catch ex As Exception
    'handle the way you want
  End Try
End Sub
Private Sub doProcess()
  'process spBuffer
End Sub
Did you observe anything in the code above? I marked it as ‘imp, check it. You see spObj.ReadExisting() actually doesn’t read existing line accurately as there is something wrong with spObj_DataReceived(). That is the reason you need to keep concatenating string till you get vbCr or vbLf in the string. I am handling it with those two form level variables i.e. spDrLine and spBuffer. Rest is self explanatory.

Excel | Reverse Calculation With Goal Seek

We are all aware, how dynamically Excel does calculations. Telling you the same with an example would be like this – You have a value 10 at A1, 5 at B1 and a formula ‘=A1*B1’at C1 which results 50; Now if you change A1 to 20 you will see 100 at C1. That is what exactly I meant. How about changing C1 to 70 so that A1 will be changed automatically to 14? Try out. What happened? Nothing, Right?
Goal Seek comes into existence in these scenarios. In order to prove its important, let us jump into a more complex scenario. Let us have a look on the following scenario.
You are paying a premium of Rs.1000/- every year for 15 years with a return of 9.23% on it. What would be your return at the end of 15th year? What will be your balance at the end of every year? What will be your interest receivable? You will get all these answers by applying the following formulas.

B5 formula is ‘=0+$A$2’.
C5 formula is ‘=B5*$B$2/100’.
D5 formula is ‘=B5+C5’.
B6 formula is ‘=D5+$A$2’ Copy till B19.
C6 formula is ‘=B6*$B$2/100’ Copy till C19.
D6 formula is ‘=B6+C6’ Copy till D19.
D2 formula is ‘=$D$19’.
If you change premium (Cell A2) from Rs.1000 to any other value, you will see every related thing changes and your return (Cell D2) is reflected automatically. As you see here, if you pay Rs.1000 every year for 15 years, you are getting Rs.32656.46.
Now the question is, if you want Rs.30000.00 at the end of 15 years, what premium do you need to pay every year? Are you thinking? Any answer? All Right let’s do it. Click Data Menu > What if analysis > Goal Seek and Enter $D$2 {at Set Cell}, 30000 {at To Value}, $A$2 {at By Changing Cell} > OK.
Now, you can see what happens after clicking OK button. It has done a complete set of reverse calculation to arrive Rs.30000.00 as end result. Did you understand what complex task is done so easy and quickly for you?
I hope your imagination will, now, go to any extent and you be able to apply these reverse calculation to take best financial and its related decisions. Bye for now! Take Care!