Monday, November 22, 2004

ASP.NET: Web user controls, the dynamic way

One of the issues to overcome using Delphi.net and off course ASP.NET was how can I create my special webuser control dynamicaly in runtime.

First off all you'll have to add the unit, containing the webusercontrol to your uses clause.
The following code shows how you can add it:

procedure TWebForm1.AddWuControl;
var wu : TMyWebUserControl;
begin
wu := TMyWebUserControl(LoadControl('MyWebuserControl.ascx'));
pnlTest.Controls.Add(wu);
end;

Quit simple isn't it?
I generally use this technique when a repeater gets to complicated. Justing looping a recordset (? Ok DataReader) and create controls on a specific panel.

No comments:

Use an image as your UIBarButtonItem

Using an image as your UIBarButtonItem in your navigationcontroller bar can only be achieved by using a common UIButton as the BarButtonItem...