Banner Ad

Tuesday, September 10, 2013

Team Foundation Server 2012 – An Introduction

By Francis   Posted at   1:19 PM   Team Foundation Server 2012 No comments
TFS – An Introduction:
                          In my organization, we have recently started using Team Foundation Server 2012. Previously we have worked on the Visual Source Safe for version controlling. Adopting with this new technology is hard at first. After using day by day, it’s awesome. Now I felt that TFS is really awesome product from Microsoft.


TFS not just give an option for version control. Its gives more apart from version controlling like branching etc.  The below are the few important advantages of TFS. If I, missed or added wrongly feel free to contact me or leave a comment.
  • With branching we can easily merge the changes between the projects.
  • We can control the entire project activity with TFS.
  • We can define the source code standards (here called policies) and check against the source code we wrote in Visual studio. That is if any of the code violates the coding standards, we can easily figure it out with this feature.
  • We can assign task to entire team and fill the completed and completion dates.
  • The above are the some  advantages of TFS. In the feature articles I will give the detail explanation of TFS. Keep in touch!
Hope this helps to understand the basic of TFS.

Wednesday, August 28, 2013

ASP.Net: Format Number into 2 digits Using Java script


               In this post we are going to see that how to formatting the number entered in the server side text box.


<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="Blogging.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        // This function is called when the focus moved from Text Box
        function formatNumber() {
            // Get the Controls value
            var strAmount = document.getElementById("<%=txtAmount.ClientID%>").value;
            // Replace the prefix and suffix spaces
            var dblAmount = strAmount.replace(/^s+|s+$/g, '');
            //check the input is not a empty string
            if (dblAmount != '') {
                // check the input is a valid number
                if (isNaN(dblAmount)) {
                    // Alert the User
                    alert("Please enter only whole number");
                    // Clear the values
                    document.getElementById("<%=txtAmount.ClientID%>").value = "";
                }
                else {
                    // Append zeros
                    var strAmount = dblAmount + "." + "00";
                    //strAmount = strAmount.replace(/^s+|s+$/g, '');
                    document.getElementById("<%=txtAmount.ClientID%>").value = strAmount;
                }
            }
        }
        // Called when the focus set on the Text Box
        function removeZeros() {
            // Get the Controls value
            var strAmount = document.getElementById("<%=txtAmount.ClientID%>").value;
            // Replace the prefix and suffix spaces
            strAmount = strAmount.replace(/^s+|s+$/g, '');
            // Replace the Zeros and Dot
            var dblAmount = strAmount.replace(".00", "");
            //check the input is a valid number
            if (dblAmount != '') {
                // check the input is a valid number
                if (isNaN(dblAmount)) {
                    alert("Please enter only whole number");
                }
                else {
                    // Assign the value to text box
                    document.getElementById("<%=txtAmount.ClientID%>").value = dblAmount;
                }
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    Enter A Whole Number :
    <asp:TextBox ID="txtAmount" runat="server" onblur="formatNumber();" onfocus="removeZeros();">
    </asp:TextBox>
    </form>
</body>
</html>

Let’s have a look at that line:

<asp:TextBox ID="txtAmount" runat="server" onblur="formatNumber();" onfocus="removeZeros();"></asp:TextBox> 

Which declares ASP.Net text box,  with 2 client side events “onblur” and “onfocus”.

Onfocus – used to call a javascript function when the focus set on that control. That is when you click on the text box this will fired.
Onblur – Used to call a javascript function when the focus is moved to next control. When the user press tab key this event triggered.

         In the javascript functions “formatNumber” and “removeZeros” I have used some regular expression to remove the leading and trailing spaces.
I have previously explained the purpose of ClientID in this post.

To run this program, just copy and paste that code in a webform and hit F5.

Please go thru the comments in the javascript for better understanding.

Provide your valuable comments to improve my articles.


Hope this helps a bit!

Monday, August 26, 2013

Visual Studio Tips &Tricks: 4 – Solution File Not Found

By Francis   Posted at   11:19 AM   Visual Studio Tips and Tricks No comments
                  Last night I have tried to add a Blank Solution and then to add a website under that solution. First I have added that blank solution. Solution added successfully. When I added the Website under that solution, then the Solution has been hidden only website alone displayed in Solution Explorer.

Website With out Solution

To Bring the Solution file, go to the Tools -> Option Menu.

Select “Projects and Solutions” and check the check box with the text “Always show solution”. 
Option Window in Visual Studio
That’s all now the solution file displayed in the top of web site like below.
Website with Solution

Hope this helps a bit!

Thursday, August 22, 2013

Visual Studio Tips &Tricks : 3 – Ctrl+, - File Search Easy

By Francis   Posted at   11:28 AM   Visual Studio Tips and Tricks No comments
                 Whenever the project grows large it’s hard to take the necessary file in Visual studio. That is we need to traverse a lot of folders or sub folders if we know the file where it was exactly. 

                  Sometimes, when you deployed in a new project, if another user just mention a file name and ask you take a look about particular logic its really painful to find that file where it was located exactly.

                   At these times the hot key combination Ctrl + , (Control Key with Semicolon) comes a handy. Which opens “Navigate To” window in which if we started type it will list down the file name in a quicker manner. So that we can pick up the file easily.
Navigate To - Window 

                   It not only listed the File names, it also list down the method name too. So whether you search a method or File use the 
shortcut key Ctrl+, and navigate quicker.

Please give your valuable comments which improves my future articles!

Hope this helps a bit!

Wednesday, August 21, 2013

Access ASP.Net Server Control in Client Side Using Javascript

By Francis   Posted at   12:18 PM   Client ID in ASP.Net No comments
              Some time, we have a situation to access the server side ASP.Net controls and its values using Client side script like java script.  In this post I’m going to explain how to do that with a simple example.

A word about Client ID:

              As all of us know, that server side controls are submitted and processed by the ASP.Net engine, which emits the respective HTML to the browser. At that time the ASP.Net engine takes the server controls and provide ID (which can be varied across asp.net versions) for it.

            Consider the below example, which has 3 text boxes, after entered values in first 2 text boxes when the user clicks the button then javascript function called which will add the values and put it in 3rd text box. These controls are Server controls.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function Add() {
            var intFirstNo = document.getElementById("<%= txtFirstNo.ClientID %>").value;
            var intSecondNo = document.getElementById("<%= txtSecondNo.ClientID %>").value;
            var intResult = parseInt(intFirstNo)  +  parseInt(intSecondNo);
            document.getElementById("<%= txtResult.ClientID %>").value = intResult;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <table>
<tr>
            <td>
                Enter First Number:
            </td>
            <td>
                <asp:textbox clientidmode="Predictable" id="txtFirstNo" runat="server"></asp:textbox>
            </td>
        </tr>
<tr>
            <td>
                Enter Second Numer:
            </td>
            <td>
                <asp:textbox id="txtSecondNo" runat="server"></asp:textbox>
            </td>
        </tr>
<tr>
            <td>
                Addition is:
            </td>
            <td>
                <asp:textbox id="txtResult" runat="server"></asp:textbox>
            </td>
        </tr>
<tr>
        <td align="center" colspan="2">
        <asp:button id="btnResult" onclientclick="Add(); return false;" runat="server" text="Calculate">
        </asp:button></td>
        </tr>
</table>
</form>
</body>
</html>

Consider this java script line:

var intFirstNo = document.getElementById("<%= txtFirstNo.ClientID %>").value;

                When the above line is read by the ASP.Net engine, it will search the Server control ID “txtFirstNo” and get the respective client ID, which has been assigned by ASP.Net engine.  In other words, ASP.Net get the Client ID for that Server control “txtFirstNo” and substitute there in between the double quotes. As a result when we saw the view source of the page we can read that above one as follows:

var intFirstNo = document.getElementById("txtFirstNo").value;

We also return false (in line no 42) after call the javascript function "Add" to avoid the postback when we click the button.

Just copy the above sample in a webform and try it yourself!

Please leave your valuable comment which improves every Article!

Hope this helps a bit! 
Connect with Us