Tuesday 26 April 2016

How To Use Progress Bar With Ajax Request Jquery


Use The Code Below To Have Progress Bar with %age Complete For Fetching Data

Preview Of Jquery Ajax Loader
HTML CODE 

<div id="progressbar">
    <div class="progress-label">Loading...</div>

</div>

CSS CODE

.progress-label {
    float: left;
    margin-left: 50%;
    margin-top: 5px;
    font-weight: bold;
    text-shadow: 1px 1px 0 #fff;

}

Javascript / Jquery Code

  $(function () {
      var progressbar = $("#progressbar"),
          progressLabel = $(".progress-label");

      progressbar.progressbar({
          value: false,
          change: function () {
              progressLabel.text(progressbar.progressbar("value") + "%");
          },
          complete: function () {
              progressLabel.text("Complete!");
          }
      });

      function progress() {
          var val = progressbar.progressbar("value") || 0;

          progressbar.progressbar("value", val + 1);

          if (val < 99) {
              setTimeout(progress, 100);
          }
      }

      setTimeout(progress, 3000);

  });

Thursday 14 April 2016

Convert Json Array To Table Format in AngularJS


The Following Code will Split Json Array Into Tabulated Format with Rows

HTML CODE

<div id="div1">
</div>

CSS CODE

#mytable,td{
    border:1px solid blue;
}

Javascript Code

var obj=[
    {
        id : "001",
        name : "apple",
        category : "fruit",
        color : "red"
    },
    {
        id : "002",
        name : "melon",
        category : "fruit",
        color : "green"
    },
    {
        id : "003",
        name : "banana",
        category : "fruit",
        color : "yellow"
    }
]
var tbl=$("<table/>").attr("id","mytable");
$("#div1").append(tbl);
for(var i=0;i<obj.length;i++)
{
    var tr="<tr>";
    var td1="<td>"+obj[i]["id"]+"</td>";
    var td2="<td>"+obj[i]["name"]+"</td>";
    var td3="<td>"+obj[i]["color"]+"</td></tr>";
 
   $("#mytable").append(tr+td1+td2+td3);

}

Output Image


Friday 4 March 2016

How To Fix Call to undefined function apache_get_modules()



Fatal error:  Call to undefined function apache_get_modules() in
apache_get_modules() is only available when the PHP is installed as a module and not as a CGI. This is the reason why you cannot use this function and suffering from the error . The other reason would be caused by the disable_functions directive in your php.ini . you can use the following written php code to check whether rewrite module is enabled or not in your case while using CGI server API

<?php
if (is_mod_rewrite_enabled()) {
  print "The apache module mod_rewrite is enabled.<br/>\n";
} else {
  print "The apache module mod_rewrite is NOT enabled.<br/>\n";
}

/**
 * Verifies if the mod_rewrite module is enabled
 *
 * @return boolean True if the module is enabled.
 */
function is_mod_rewrite_enabled() {
  if ($_SERVER['HTTP_MOD_REWRITE'] == 'On') {
    return TRUE;
  } else {
    return FALSE;
  }
}
?>

To Check whether you are running Php Under CGI or Apache you can use procedure below
Create a check_phpinfo.php file and Write PHP Code Written Below -
<?php

// Show all information, defaults to INFO_ALL
phpinfo();

?>
Then the file and Navigate to Url like - www.example.com/check_phpinfo.php and It will show you php file in server
In Four line you can see "Server API CGI/FastCGI" That Denotes you are using PHP under CGI / Fast CGI

Saturday 27 February 2016

Freedom 251 Announced Cash on Delivery


Ringing Bells president Ashok Chadha announced that the Rs 251 (less than $4) "Freedom 251" smartphone customers will now be required to make payment only when the smartphone is delivered to them.

The company plans to give 25 lakh handsets in the first phase before June 30.

It received 30,000 orders on the first day and rest of the customers will be selected via first-come-first-serve basis as it received a mammoth over seven crore registrations.

Saturday 28 November 2015

Saturday 19 September 2015

Method Overloading And Method OverRiding

Method Overloading refers to Concept the defining the one or more functions or methods with same name with different Parameter Length or Parameter Types . So Functions are differenciated by their signature or Parameters .

Example For Method OverLoading

//Overloading
public class test
{
    public void getStuff(int id)
    {}
    public void getStuff(string name)
    {}
}
 
Method OverRiding is Totally Different Concept As Compared to Method Overloading . Method OverRiding Refers to Redefining the Function that Correspond to Some Other Class and Accessed Using Inheritance .

The Concept of Method OverRiding depends on Two Keywords - Virtual and OverRide

In Simple Scenario to Explain Method OverRiding with Example is Lets Assume We have a Base Class with function Sample() in Base Class then The Oher class that Derived From that Base Class Can Redefine the Functionality of That Sample() Function refers to Concept of Method OverRiding .

Example1  For Method OverRiding

class BC
{
  public virtual void Display()
  {
     System.Console.WriteLine("BC::Display");
  }
}

class DC : BC
{
  public override void Display()
  {
     System.Console.WriteLine("DC::Display");
  }
}

class Demo
{
  public static void Main()
  {
     BC b;
     b = new BC();
     b.Display();    

     b = new DC();
     b.Display();    
  }
}

Output

BC::Display
DC::Display
 

Example1  For Method OverRiding

//Overriding
public class test
{
        public virtual getStuff(int id)
        {
            //Get stuff default location
        }
}

public class test2 : test
{
        public override getStuff(int id)
        {
            //base.getStuff(id);
            //or - Get stuff new location
        }
}

 

 

Value Types Vs Reference Types Dotnet


Stack and heap

In order to understand stack and heap, let’s understand what actually happens in the below code internally.

public void Method1()
{
    // Line 1
    int i=4;

    // Line 2
    int y=2;

    //Line 3
    class1 cls1 = new class1();
}


It’s a three line code, let’s understand line by line how things execute internally.
  • Line 1: When this line is executed, the compiler allocates a small amount of memory in the stack. The stack is responsible for keeping track of the running memory needed in your application.
  • Line 2: Now the execution moves to the next step. As the name says stack, it stacks this memory allocation on top of the first memory allocation. You can think about stack as a series of compartments or boxes put on top of each other.
  • Memory allocation and de-allocation is done using LIFO (Last In First Out) logic. In other words memory is allocated and de-allocated at only one end of the memory, i.e., top of the stack.
  • Line 3: In line 3, we have created an object. When this line is executed it creates a pointer on the stack and the actual object is stored in a different type of memory location called ‘Heap’. ‘Heap’ does not track running memory, it’s just a pile of objects which can be reached at any moment of time. Heap is used for dynamic memory allocation.

Why String Are Value Types Csharp Dotnet


The distinction between reference types and value types are basically a performance tradeoff in the design of the language. Reference types have some overhead on construction and destruction and garbage collection, because they are created on the heap. Value types on the other hand have overhead on method calls , because the whole object is copied rather than just a pointer.

Because strings can be  much larger than the size of a pointer, they are designed as reference types. Also, as Servy pointed out, the size of a value type must be known at compile time, which is not always the case for strings.

Strings aren't value types since they can be huge, and need to be stored on the heap. Value types are stored on the stack. Stack allocating strings would break all sorts of things: the stack is only 1MB, you'd have to box each string, incurring a copy penalty, you couldn't intern strings, and memory usage would balloon, etc

That is why a string is really immutable because when you change it even if it is of the same size the compiler doesn't know that and has to allocate a new array and assign characters to the positions in the array. It makes sense if you think of strings as a way that languages protect you from having to allocate memory on the fly 

Boxing And Unboxing in DotNet

Boxing and unboxing

I Recommend to Go to this link to Read about Value Types and Reference Types Before Going To Understand the concept of Boxing and Unboxing

Value Types Vs Reference Types Dotnet
http://geeksprogrammings.blogspot.in/2015/09/value-types-vs-reference-types-dotnet.html

Boxing and unboxing are the most important concepts you always get asked in your interviews. Actually, it's really easy to understand, and simply refers to the allocation of a value type (e.g. int, char, etc.) on the heap rather than the stack.

Boxing

Implicit conversion of a value type (int, char etc.) to a reference type (object), is known as Boxing. In boxing process, a value type is being allocated on the heap rather than the stack.

Unboxing

Explicit conversion of same reference type (which is being created by boxing process); back to a value type is known as unboxing. In unboxing process, boxed value type is unboxed from the heap and assigned to a value type which is being allocated on the stack.

For Example
    // int (value type) is created on the Stack
    int stackVar = 12;
    
    // Boxing = int is created on the Heap (reference type)
    object boxedVar = stackVar;
    
    // Unboxing = boxed int is unboxed from the heap and assigned to an int stack variable
    int unBoxed = (int)boxedVar;


Real Life Example

    int Val_Var = 10;
    ArrayList arrlist = new ArrayList();
    
    //ArrayList contains object type value
    //So, int i is being created on heap
    arrlist.Add(Val_Var); // Boxing occurs automatically Because we are Converting int to Object Type This is Called Boxing
    
    int j = (int)arrlist[0]; // Unboxing occurs

Performance implication of boxing and unboxing

In order to see how the performance is impacted, we ran the below two functions 10,000 times. One function has boxing and the other function is simple. We used a stop watch object to monitor the time taken.
The boxing function was executed in 3542 ms while without boxing, the code was executed in 2477 ms. In other words try to avoid boxing and unboxing. In a project where you need boxing and unboxing, use it when it’s absolutely necessary.

Boxing And Unboxing in DotNet
Boxing And Unboxing in DotNet 



 

 

Thursday 20 August 2015

Difference Between Stored Procedure and Functions Sql

Stored Procedure and Functions

 

1. Function Must Return Value

   For Stored Procedure it's Not Must to return value it's optional 

2. Stored Procedures are pre-compile objects which are compiled for 
first time and its compiled format is saved which executes (compiled code) whenever it is called 

But Function is compiled and executed every time when it is called

3. Function can Accept only Input Parameters
   But Stored Procedure Can Accept Both Input and Output Parameters

4. Functions can be called from Procedure whereas Procedures cannot be called from Function

5. Functions Like Views only Accept Data Select Statements It does not Allow the Permanent Storage of data so it does not allows DML statements like Insert , Update , Delete

Whereas Store Procedure Allows All type of DML statements like Insert , Update and also Select Statements.

6. Funtions can be used in Select Statements like views to View data 
But Stored Procedure Cannot be Embedded in Select Statements

7.
 

Difference Between Views And StoredProcedure Sql

Stored Procedure Vs Views


1. Stored Procedure are collection of pre-executed sql Statements that accepts parameters as input and depending on input parameters passed gives the Output Result

Views Act like Virtual Tables That Contains set of Rows and Columns from multiple original table of Database according to defined Query Commands

2. Stored Procedure Cannot be Used as Large Building Block or we can simply say It cannot be treated as tables in large queries 

But Views Can be treated like tables we can Use Views similar to table and execute select statements on Views Similar to Tables

3. Stored Procedures Allow the Use of Data Manipulation Command like Insert Data , Update data on Table or Schemas To Manipulate Data

But Views Cannot have Data Manipulation Command It can only give list of data or View of data based on set of Queries in it . Views cannot be used to Permanently store data in database it allows just to view the data.

4. Views  can have  only one Select Statement Allowed To Use

Store Procedure Can Use Various Set of Statements That also Include If-Else Statements

5. View is a virtual table that only exists when you use the view in a query. Its considered virtual table because it acts like a table, and the same operations that can be performed on a table can be performed on a view. Virtual table doesn't stay in the database, it gets created when we use the view and then delete it. 

But Stored Procedure Physically Exist 

6. Views are Used for Providing Security to data So that by using the Views we can View only Particular view of the schema to the user Not the Full View with required columns. Their is no physical presence of view data anywhere in database.

Stored Procedure allows to perform any type of data Manipulation operation But We can also Put Security Permission on Store Procedure In order to Restrict its Access From Unauthorized User


7. Code Sample For Stored Procedure and Views
/*
This Stored procedure is used to Insert value into the table tbl_students. 
*/

Create Procedure InsertStudentrecord
(
 @StudentFirstName Varchar(200),
 @StudentLastName  Varchar(200),
 @StudentEmail     Varchar(50)
) 
As
 Begin
   Insert into tbl_Students (Firstname, lastname, Email)
   Values(@StudentFirstName, @StudentLastName,@StudentEmail)
 End
 
 
/*
View Example
*/
CREATE VIEW [Category Sales For 1997] AS

SELECT DISTINCT CategoryName,Sum(ProductSales) AS CategorySales

FROM [Product Sales for 1997]

GROUP BY CategoryName 

Saturday 1 August 2015

Jquery Full Calender Integrated With ASP.NET


Jquery Full Calender Integrated With ASP.NET


- First you need to define the function in Code-Behind using c# or vb.net that will make a Class that contains the similar properties that is required by Jquery full calendar to Fill the Calendar

- Then We Use Jquery Ajax and make request to that function that will pass some data that you can fill manually or you can also fetch that from database and then return that to this Ajax Request

- Now use the Code below to Plot then on Full Calendar

If you have any problem setting this please tell me in comments I am here to help you setting this up

Download Full Solution Code Here . Don't Forget to Share Us on Social Media

Code To Fetch Events Using Jquery


 <script type="text/javascript">
        $(document).ready(function () {
            $.ajax({
                type: "POST",
                contentType: "application/json",
                data: "{}",
                url: "Default.aspx/GetEvents",
                dataType: "json",
                success: function (data) {
                    $('div[id*=fullcal]').fullCalendar({

                      
                        header: {
                            left: 'prev,next today',
                            center: 'title',
                            right: 'month,agendaWeek,agendaDay'
                        },
                        editable: true,
                        events: $.map(data.d, function (item, i) {
                            var event = new Object();
                            event.id = item.EventID;
                            event.start = new Date(item.StartDate);
                            event.end = new Date(item.EndDate);
                            event.title = item.EventName;
                            event.url = item.Url;
                            event.ImageType = item.ImageType;
                            return event;
                        }), eventRender: function (event, eventElement) {
                            if (event.ImageType) {
                                if (eventElement.find('span.fc-event-time').length) {
                                    eventElement.find('span.fc-event-time')

.before($(GetImage(event.ImageType)));
                                } else {
                                    eventElement.find('span.fc-event-title')

.before($(GetImage(event.ImageType)));
                                }
                            }
                        },
                        loading: function (bool) {
                            if (bool) $('#loading').show();
                            else $('#loading').hide();
                        }
                    });
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    debugger;
                }
            });
            $('#loading').hide();
            $('div[id*=fullcal]').show();
        });
        function GetImage(type) {
            if (type == 0) {
                return "<br/><img src = 'Styles/Images/attendance.png' style=

'width:24px;
height:24px'/><br/>";
            }
            else if (type == 1) {
                return "<br/><img src = 'Styles/Images/not_available.png' style=

'width:24px;
height:24px'/><br/>";
            }
            else
                return "<br/><img src = 'Styles/Images/not_available.png' style=

'width:24px;
height:24px'/><br/>";
        }

    </script>


Web Method In C# that Pass the Event to Jquery Ajax Request


  [WebMethod]
        public static IList GetEvents()
        {
            IList events = new List<Event>();
            for (int i = 0; i < DateTime.DaysInMonth(DateTime.Now.Year, 


DateTime.Now.Month); i++)

            {
                events.Add(new Event
                {
                    EventName = "My Event " + i.ToString(),
                    StartDate = DateTime.Now.AddDays(i).ToString("MM/dd/yyyy"),
                    EndDate = DateTime.Now.AddDays(i+1).ToString("MM/dd/yyyy"),
                    ImageType = i % 2,
                    Url = @"http://www.google.com"
                });
            }
            return events;
        }

Class To Define the Event


 public class Event
    {
        public Guid EventID { get { return new Guid(); } }
        public string EventName { get; set; }
        public string StartDate { get; set; }
        public string EndDate { get; set; }
        public int ImageType { get; set; }
        public string Url { get; set; }
    }