Tag Archives: JQuery

Creating Custom Asp.Net Web API using Handler .ASHX Also Example On Using It With JQuery And WebRequest

This blog post is about custom Asp.Net Web API and it is not like standard Web API using Web Api Controllers, Url routing etc.
I use general term or concept of Web API that is simply programming interface in a web. This can be done with many ways. Later on, the standard Microsoft Asp.Net Web API will be presented in this blog. API is just an additional layer in application usually to access data. Web API can be consumed by any device or method that support HTTP. With that concept, I use Handler .ASHX to make an Web API. This post shows custom Web API used by Client script with JQuery also by Asp.Net Server Control. I give those examples in below list. Steps for creating custom Web API using .ASHX:

  1. Create a Web Project
  2. Add new class as Model to represent data: (Persons.cs)
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    public class Persons
    {
        List<Person> list;
    	public Persons()
    	{
            list = new List<Person>()
            {
                new Person() { Id=1, FirstName="John", LastName="Doe", Department="A" },
                new Person() { Id=2, FirstName="Jane", LastName="Voltus", Department="A"},
                new Person() { Id=3, FirstName="Joseph", LastName="Chow", Department="B"}
            };
    
    	}
    
        public List<Person> getPersonList() {
            return list;
        }
    
        public void addPerson(Person p)
        {
            list.Add(p);
        }
    
        public void deletePerson(int Id)
        {
    		//code to delete
        }
        
    }
    
    public class Person
    {
        public int Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Department { get; set; }
    }
    

    Off course you can change to use database connection and so on.

Continue reading

JQuery or Asp .Net Ajax Controls, What is your choice ? Why dont combine them ?

JQuery

JQuery used on client script. It really helps to fasten javascript or client script development.

JQuery also has package to make nice User Interface by using JQuery UI. JQuery UI has many themes that makes it more flexible and usable by developer.

Ajax functionality is one of JQuery strong benefit. Again, easy and fast client Ajax development also platform independent makes JQuery is a favorite and popular Javascript framework.

Asp .Net Ajax Toolkit and ScriptManager

Asp .Net has its own Ajax Controls. There are main components of Asp .Net Ajax controls which are ScriptManager, UpdatePanel, and Triggers. ScriptManager is a must have controls to enable Ajax.

Those controls are server control by attribute runat=”server”. So that Ajax submission will be done with .Net powerfull script and also VS intellisense. Server side script in Asp .Net is easy to manage. Has relatively less lines of code than any technology by help of so many .Net references that available. OOp implements automatically so that developer can make their best practice on OOP design.

Those reasons make general and Ajax Server side script on Asp .Net leads on easiness and fast for application development.

Asp .Net Ajax toolkit has client side script that act like JQuery to handle client development. Also it has many controls for User Interface development. With this Asp .Net functionallities, client development also can be fasten then using plain javascript.
Continue reading

OOP PHP Progress Bar For Any Purpose

Many ways to create a progress bar but in this blog post I give example on PHP Progress bar built with OOP.
The reason I use OOP is that the class can be used again for any purpose which need progress bar.

We need interface OOP object which contains three methods which are get_max() returns maximum value that progress bar will have,
get_progress() returns current progress value or progress percentage. This progress percentage value sets progress bar value and do_work() to do a real work like database or files operation or else.

I use JQuery to draw Progress Bar in User Interface because of simplicity to make it with JQuery. I assume that you already know basic of progress bar and JQuery.

Continue reading