Monthly Archives: April 2012

Useful PHP DataTable Class Example To Store Objects including Recordset


Any table like objects like array and recordset have same structure. They have rows and columns.
Usually column is a key and row is a value.

A recordset that comes from database ‘select’ operation usually stored in array or OOP object variable on MVC concept or any kind of business logic and view layer.
A web page access this variable to show its data. View layer only include database and datatable class files. So web page users doesn’t access database operational directly.

With this concept, I have build a simple DataTable class to store those kind of objects.
This DataTable has functions to add columns and rows and get their values so that we can extract information from DataTable with easy and use same methods repeatedly.
Also we can get DataTable object value on another page with SESSION functionality.

Continue reading

Starting & Aborting/Cancelling Asp .Net Ajax Request Techniques

Starting an Ajax request is easy task. We can use ScriptManager, UpdatePanel and UpdateProgress controls but aborting it requires more client script.
Common web example of abort/cancel ajax request has abort() method to XMLHttpRequest. On the other hand Asp .Net has its own way to accomplish this.

Example 1 (Sys.WebForms.PageRequestManager)

  1. Create new Website Application
  2. Add new Webform, Default.aspx:
    <html xmlns="">
    <head runat="server">
        <script type="text/javascript">
            function aborttask() {
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            <asp:UpdatePanel ID="updpanel" runat="server">
                    <asp:Button ID="btnstart" Text="Start Ajax for 10 seconds" runat="server" /> &nbsp;
                    <asp:Button ID="btnstop" Text="Abort" runat="server" OnClientClick="aborttask()" /><br />
                    <asp:Label ID="msg" runat="server"></asp:Label>
            <asp:UpdateProgress ID="updprog" runat="server" AssociatedUpdatePanelID="updpanel">
                <ProgressTemplate>Sleeping ..</ProgressTemplate>

    Continue reading

[Resolved]Cannot Consume/Access/Use Asp .Net Classes in App_Code / Bin folder and WebService ‘Compilation Error’


We can create Asp .Net classes or bussiness objects inside App_Code or using compiled library .dll file in Bin folder.
Alternatively classes may be write inside WebService. If nothing is wrong then we can access our web app classes when it is launched via Visual Studio.
Unfortunately, after we deploy it to IIS and try to access deployed classes or WebService an error “Compilation error .. Type xxx is not defined ..” occurs.


Let’s make a New Website Asp .Net Empty Web Application to make problem and solution clear.
Continue reading

ASP .Net Ajax BackgroundWorker Example Using Client Script & PageMethods

At A Glance

BackgroundWorker commonly use on Winform application. Basically it is an asynchronous process. Its thread is separate from main.
On user point of view backgroundworker works on background. Developers codes Winform async process easily with BackgroundWorker.
Here’s a Winform brief code of BackgroundWorker:

BackgroundWorker bgw = new BackgroundWorker();
bgw.WorkerReportsProgress = true;
bgw.WorkerSupportsCancellation = true;
bgw.DoWork += new DoWorkEventHandler(bgw_DoWork);
bgw.ProgressChanged += new ProgressChangedEventHandler(bgw_ProgressChanged);
bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgw_RunWorkerCompleted);

void bgw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)

void bgw_ProgressChanged(object sender, ProgressChangedEventArgs e)

void bgw_DoWork(object sender, DoWorkEventArgs e)

However on Asp .Net Web Application there is no default BackgroundWorker server control. We have to use Asp .net Ajax to make a web async process.
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

Quickly Mastering: Create And Use Asp .Net Web Service From Basic, Database Access To Ajax-Enabled


Web services are components on a Web server that a client application can call by making HTTP requests across the Web. ASP.NET enables you to create custom Web services or to use built-in application services, and to call these services from any client application

Web Services are an integral part of the .NET framework that provide a cross-platform solution for exchanging data between distributed systems. Although Web Services are normally used to allow different operating systems, object models and programming languages to send and receive data, they can also be used to dynamically inject data into an ASP.NET AJAX page or send data from a page to a back-end system. All of this can be done without resorting to postback operations.

Web Service In Code

Web Service in Asp .Net is an object that can be accessed in the same way as a class.
Website project must add Web reference to a WebService’s Url address so that the website can access it.
In code point of view, writing access to WebService is same as accessing a regular class in Asp .Net. This regular class usually located in App_Code folder.
WebService located at a web server and reference it through http protocol.

Inside WebService code file is a class and its member. We can put class member, properties and methods in WebService. We can build WebService to operate with files, database etc Continue reading

Understanding Polymorphism As Wrapper Class With PHP Example


In programming languages, polymorphism means that some code or operations or objects behave differently in different contexts.
It able to process objects differently depending on their data type or class. More specifically, it is the ability to redefine methods for derived classes.
So it is overloading parent object. Child objects has all methods in their parent and childs can have more methods.

Several parent object type to support polymorphism are class, abstract and interface. In this post, I use ‘abstract’ class as parent to give polymorphism demo due to I will using it as wrapper class.
What I mean of wrapper class is I do not have to write same code over and over again in every child classes. I only have to write once in the abstract functions.
Abstract class can not have an instance or real object. It is only model of the class design but the different from ‘interface’ that abstract can have a body inside function declaration.

To explain the differences between abstract, interface and general class, look at code below: Continue reading