Autor Beitrag
Stoffel1984
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 219

Win NT, Win 2000
D6 Prof
BeitragVerfasst: Do 24.08.06 21:34 
Hallo,

ich entwickele mit D2005 eine ASP.NET Anwendung.
Will ich nun ein Panel zur Laufzeit erzeugen, stoße ich auf folgendes Problem.
Mit create kann ich zwar die Instanz des Panels erzeugen, aber ich sehe das Panel nicht auf der Webseite.
Ein Parent kann ich ja nicht setzen. Hat jemand ne Idee wie ich das Problem lösen könnte?

Danke, Steffen
senidex
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

WIN XP

BeitragVerfasst: Sa 26.08.06 19:48 
Titel: ASP.NET dynamisch einfügen
Hallo Stoffel1984,
heir ein paar Beispiele

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
procedure TWebForm1.Page_Load(sender: System.Object; e: System.EventArgs);
var
    pnl : System.Web.UI.WebControls.Panel;
begin

 // Fall 1 Panel wird einfach auf die Seite gelegt
 pnl:=System.Web.UI.WebControls.Panel.Create;
 pnl.ID:='Panel2';
 pnl.ForeColor:=system.Drawing.Color.Black;
 pnl.BackColor:=system.Drawing.Color.Yellow;
 pnl.Width:=100;
 self.Controls.Add(pnl);

 // Fall 2: Panel wird in ein bereits bestehenden Panel(=panel1) eingefügt
 pnl:=System.Web.UI.WebControls.Panel.Create;
 pnl.ID:='Panel3';
 pnl.ForeColor:=system.Drawing.Color.Black;
 pnl.BackColor:=system.Drawing.Color.aqua;
 pnl.Width:=100;
 self.panel1.Controls.Add(pnl);

 // Fall 3: Panel wird in eine bereits im Formular befindliche PLACEHOLDER-Komponente eingefügt
 pnl:=System.Web.UI.WebControls.Panel.Create;
 pnl.ID:='Panel4';
 pnl.ForeColor:=system.Drawing.Color.Black;
 pnl.BackColor:=system.Drawing.Color.Blue;
 pnl.Width:=100;
 PlaceHolder1.Controls.Add(pnl);
end;


Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
Stoffel1984 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 219

Win NT, Win 2000
D6 Prof
BeitragVerfasst: So 27.08.06 23:12 
Vielen Dankm, funktioniert wunderbar!

Gruß Steffen
Stoffel1984 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 219

Win NT, Win 2000
D6 Prof
BeitragVerfasst: Do 31.08.06 16:21 
Es ist noch ne kleine Frage aufgetreten.
Wie ist es mir möglich das Panel (beim gridlayout) vertikal und horizontal auszurichten!?

Danke!