APNSoft Controls [4.5.2.20]
Adding controls to an ASP.NET Web Page
APNSoft Controls Suite does not require special handlers, modules, application settings (Web.Config), etc. There are three main ways to add APNSoft control to an ASP.NET Web Page.
- Manually.
- From Visual Studio Toolbox (recommended).
- In Code Behind.
- Manually embedding a Control into the page.
All you need to do is to add main dll library to your web application and write two lines of code on the WebForm:
- Copy the APNSoftControls.dll assembly into the Bin directory of your web application.
By default, installer puts the APNSoftControls.dll in the folder:
C:\Program Files\APNSoft Controls [Product_Version] for ASP.NET [NET_Version]\Bin\
- Add the following line of code to the top of your page:
<%@ Register TagPrefix="APNSoft" Namespace="APNSoft.WebControls" Assembly="APNSoftControls" %>
- Add corresponding code anywhere within your page to embed the control. The common syntax is:
<APNSoft:APNSoft[Control_Name] id="myID" runat="server" />
The [Control_Name] is the name of control (Menu, DataGrid, TreeView, etc.).
For example, the complete code for Menu:
<APNSoft:APNSoftMenu id="myMenu" runat="server" />
Or the code for DataGrid:
<APNSoft:APNSoftDataGrid id="myDataGrid" runat="server" />
Now you can open the page in your browser to see output.
- Adding a Control to your web application using Visual Studio.
Make sure you
have added
APNSoft Controls to your Visual Studio Toolbox. Drag the component icon from the toolbox and drop it in your web form / user control. Visual Studio will automatically copy the APNSoftControls.dll assembly to the Bin folder of your web application and will add required code to the page. All of the properties are available via Properties Panel.
- Adding a Control programmatically (in Code Behind).
For more programming flexibility you can use the built-in API of any APNSoft control. We recommend to use the PlaceHolder as a container to store dynamically added server controls on the Web page. The PlaceHolder is a standard Web Forms control.
- Copy the APNSoftControls.dll assembly into the Bin directory of your web application.
- Put the PlaceHolder somewhere on your Web page.
<asp:PlaceHolder ID="PlaceHolder1" runat="server" />
- Put code in the Page_Load() procedure in Code Behind.
[C#]
protected void Page_Load(object sender, EventArgs e)
{
//Create component instance
APNSoft.WebControls.APNSoftMenu myMenu = new APNSoft.WebControls.APNSoftMenu();
myMenu.BasePage = base.Page;
myMenu.ID = "myMenu";
//Set properties
myMenu.StructureFileURL = "~/Structures/Menu.xml";
myMenu.SkinFolder = "~/Skins/Classic/";
//Add the control to PlaceHolder
PlaceHolder1.Controls.Add(myMenu);
}
[VB.NET]
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
'Create component instance
Dim myMenu As APNSoft.WebControls.APNSoftMenu = New APNSoft.WebControls.APNSoftMenu
myMenu.BasePage = Me.Page
myMenu.ID = "myMenu"
'Set component properties
myMenu.StructureFileURL = "~/Structures/Menu.xml"
myMenu.SkinFolder = "~/Skins/Classic/"
'Add the control to PlaceHolder
PlaceHolder1.Controls.Add(myMenu)
End Sub