This technical note walks you through the process of creating a simple ASP.Net application using the ActiveGantt ASP.Net component in Visual Basic .Net.
Open the Visual Studio .Net IDE. Create a new ASP.Net web application. In the example we will create a new web application called WebApplication1 under the localhost web.

Open the WebForm1.aspx page, open the Toolbox and right click on the toolbox. Select Customize Toolbox.

The Customize Toolbox dialog will pop up. Select the .Net Framework Components Tab.

Click on the Browse button and look for the file AGVBA20.dll. This file should be located in C:\Inetpub\wwwroot\AGDemo\bin.

The Customize Toolbox dialog will now show the ActiveGanttVBACtl as part of its list.

The Toolbox must also now display the ActiveGanttVBACtl in its list of insertable controls.

Now you can insert the control into the WebForm1.aspx page.

Navigate to the C:\Inetpub\wwwroot\WebApplication1 folder, create a new folder called SessionTemp. This folder will have the purpose of storing temporary images used to draw the ActiveGantt control and will be mapped to the TempDir property of the ActiveGantt ASP.Net control, but first the ASPNET user must be given full control over it.

Right click on the new SessionTemp folder and click on properties. Click on the Security tab.

Click on the Add button. Select the ASPNET user click on the Add button and then click the OK button.

Grant the aspnet account full Control.

Go back to the Visual Studio IDE and select the ActiveGantt control in the WebForm1.aspx page. In properties look for the TempDir property and set this value to SessionTemp.

Switch to codeview in the WebForm1.aspx page and include the following code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
If Me.IsPostBack = False Then
mp_LoadControlData()
ActiveGanttVBACtl1.Draw()
Else
mp_LoadControlData()
ActiveGanttVBACtl1.Calculate()
End If
End Sub
Private Sub mp_LoadControlData()
ActiveGanttVBACtl1.Rows.Add("K1")
End Sub
Private Sub ActiveGanttVBACtl1_Click(ByVal sender As Object, _
ByVal e As System.Web.UI.ImageClickEventArgs) _
Handles ActiveGanttVBACtl1.Click
ActiveGanttVBACtl1.Draw()
End Sub
|
The sequence of the code must be identical to the one displayed above for any ASP.Net page that contains an ActiveGantt control. Draw and Calculate instructions must be present in the Page_Load event (Draw when the page is being visited by a user for the first time and calculate on subsequent postbacks). A Draw instruction must also be present in the Click event. Failure to include these instructions in this exact sequence will cause unpredictable control behaviour. We also generally include a subroutine called mp_LoadControlData were the control is drawn independent of whether it’s a postback operation or not.
When building this example a control with one Row object will show up on your browser:

Another very important programming task is to clean off the images that have been stored in SessionTemp when user sessions have expired. The following code in global.asax will accomplish this:
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
If Dir(Me.Server.MapPath("SessionTemp") & "\S" & Me.Session.SessionID & "*.png") <> "" Then
Kill(Me.Server.MapPath("SessionTemp") & "\S" & Me.Session.SessionID & "*.png")
End If
End Sub
|
Every temporary image that is stored in the TempDir Directory has a basic filename structure of S + the session ID + a date/time stamp and the extension .png. Some users prefer to have one single TempDir for all of their controls within one ASP.Net application and they use the GUID property setting which is also appended to the file names.