I was working on a problem where in the application was built upon ASP.NET / Javascript. Most of the logic of this highly dynamic application was on the client side javascript. The challenge was that the application was becoming more and more difficult to maintain as the user requirement were adding up.

Which made the javascript files so complex that it was difficult to maintain, even though “jQuery” was used as the framework. The logic was mostly enabling and disabling stuff, updating elements when the user changed something, hiding and displaying the elements.

The application was trying to do a lot of things that a excel spreadsheet does. As the stakeholder wanted the excel spreadsheet to be changed into an application.

Now the main task to do for the application was make it modular and highly maintainable. Since the key thing was javascript to make this application do its task, was something hard to change. Then working on it for a couple of days, came up with the idea of having to make the UI being generated at the server-side since most of the javascript logic was also at the server side (for the initial rendering of the page).

Using this code all I had to do was to call it using ajax and the html content is rendered and sent back as the response.

Below is some code for how to generate the ASP.Net web controls to plain text html.

using System.IO;
using System.Text;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

namespace Dilberted.Html
{
    public class DummyPage : Page
    {
        public override void VerifyRenderingInServerForm(Control control) { }

        public override bool EnableEventValidation { get { return false; } set { /* Do nothing */} }
    }

    public class HtmlGenerator
    {
        public string Generate(WebControl control)
        {
            var sBuilder = new StringBuilder();
            var sWriter = new StringWriter(sBuilder);
            var htmlTextWriter = new HtmlTextWriter(sWriter);

            var page = new DummyPage();
            page.DesignerInitialize();

            var form = new HtmlForm();
            page.Controls.Add(form);
            form.Controls.Add(control);
            control.RenderControl(htmlTextWriter);

            return sBuilder.ToString();
        }

        public string Generate(Control control)
        {
            var sBuilder = new StringBuilder();
            var sWriter = new StringWriter(sBuilder);
            var htmlTextWriter = new HtmlTextWriter(sWriter);

            var page = new DummyPage();
            page.DesignerInitialize();

            var form = new HtmlForm();
            page.Controls.Add(form);
            form.Controls.Add(control);
            control.RenderControl(htmlTextWriter);

            return sBuilder.ToString();
        }
    }
}

I love to read about Forensics (Computer) and whenever I read any article or news, get super excited. I am hoping to pursue my career in Computer Forensics, if I do get a chance.

One of the biggest challenges of forensics investigations into insider theft is that the markers computer forensics
Read the rest of this entry »


I have working on something on top of node.js and wanted to install on my hosting account. There are many tutorials available on this topic but they have some or the other thing incomplete. Hence I decided to combine all of them together and post here a working solution.

1. Create the directory to store the Node binaries

mkdir -m 755 node creates the folder used to store the Node.js binaries

2. Download & Compile Node.js

wget http://nodejs.org/dist/v0.8.0/node-v0.8.0.tar.gz
tar -xvf node-v0.8.0.tar.gz

Read the rest of this entry »


I found this nice looking slide for understanding the concept of all these new technologies (atleast for me). I thought of sharing with more people 🙂

Node.js is becoming very popular nowdays, mainly because of two reasons

  • Architecture
  • Javascript
  • There are many more things that can be done with node.js

    Read the rest of this entry »


    PHPLinq is a class library for PHP, based on the idea of Microsoft’s LINQ technology. LINQ is short for language integrated query, a component in the .NET framework which enables you to perform queries on a variety of data sources like arrays, XML, SQL server, … These queries are defined using a syntax which is very similar to SQL.

    PHP Linq Stack

      Example 1
    $rssFeed = simplexml_load_string(file_get_contents('http://blog.maartenballiauw.be/syndication.axd'));
    $result = from('$item')->in($rssFeed->xpath('//channel/item'))
    ->orderByDescending('$item => strtotime((string)$item->pubDate)')
    ->take(2)
    >select('new {
    "Title" => (string)$item->title,
    "Author" => (string)$item->author
    }');
    

    Read the rest of this entry »


    I like this.. “Technollywood” 😀


    Seems like a cool feature for Google+, and it would really help a lot of people especially the companies that benefit from Social Media. With the user base of Google+ and added advantage of the referral traffic this could be the next big thing in the Social Media marketing.


    This is another awesome product / technology from Google.. But I fear whether it is really practical or not. This technology does come with a lot of warning attached.

    May be it is just due to the fact that people might take time to adapt or take time to include in their daily life.

    But in any case I hope the technology becomes successful and one day we can also communicate without the need of our hands & control things though our voice.

    Here is Google’s “Project Glasses” ..


    Google has done it again.. nice looking tablet would be out soon and people would be after Nexus 7.

    Seems one day in future Google will become the “SKYNET” .. hehehe!


    Procedure to Install Django, Python, SVN on your HostMonster shared web hosting account.

    1. First Login to your SSH Client(Putty) using your credentials.
    2. Python
      Create a directory named “python” where your Python executable will reside.
      mkdir pythonNow download ,extract, compile and then install the source for Python 2.7.1 (We are not using Python 3.1 because currently Django does not support Python 3 and won’t for at least a year)

      wget http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tar.bz2
      tar -xjf Python-2.7.1.tar.bz2
      cd Python-2.7.1
      ./configure -prefix=$HOME/python
      make –j8 && make install
      

      make –j8 will speed up building as it will be executed in 8 concurrent threads. Read the rest of this entry »