HT make screens morf to fit the current situation?

X

xzzy

I am stuck on how to make a screen whose fields are created at runtime so it
can 'morf'' to meet the needs of the current situation.

Using <table id="Table1" runat="server">
</table>
and using code behind to write cells, rows and server controls into the
cells doesn't work ( can't programactially access a table )

I am currently trying to do:

<table id="Table1" runat="server">
<tr><td><asp:placeHolder id="PL1"/></td></tr>
<tr><td><asp:placeHolder id="PL2"/></td></tr>
</table>

and in code behind

protected System.Web.UI.WebControls.PlaceHolder PL1;
protected System.Web.UI.WebControls.PlaceHolder PL2;

and then wanting to write a server control to each placeholder and then be
able to read and write information to the server controls. But I am unable
to reference the newly created server controls.
 
G

Guest

I am stuck on how to make a screen whose fields are created at runtime so it
can 'morf'' to meet the needs of the current situation.

Using <table id="Table1" runat="server">
</table>
and using code behind to write cells, rows and server controls into the
cells doesn't work ( can't programactially access a table )

I am currently trying to do:

<table id="Table1" runat="server">
<tr><td><asp:placeHolder id="PL1"/></td></tr>
<tr><td><asp:placeHolder id="PL2"/></td></tr>
</table>

and in code behind

protected System.Web.UI.WebControls.PlaceHolder PL1;
protected System.Web.UI.WebControls.PlaceHolder PL2;

and then wanting to write a server control to each placeholder and then be
able to read and write information to the server controls. But I am unable
to reference the newly created server controls.

Actually, it is not a big problem to create a cell and a control in
it.

Instead of PlaceHolders, try following

// create first row
HtmlTableRow r1 = new HtmlTableRow();
HtmlTableCell c1 = new HtmlTableCell();
r1.Cells.Add(c1);

// create second row
HtmlTableRow r2 = new HtmlTableRow();
HtmlTableCell c2 = new HtmlTableCell();
r2.Cells.Add(c2);

Table1.Rows.Add(r1);
Table1.Rows.Add(r2);

// then you can add a control, e.g.

TextBox txt = new TextBox();
txt.ID = "mytext";
r1.Cells[1].Controls.Add(txt);
 
X

xzzy

the problem is: after the viewer adds/changes information in the textbox,
how to reference the information in the textbox

Anon User said:
I am stuck on how to make a screen whose fields are created at runtime so
it
can 'morf'' to meet the needs of the current situation.

Using <table id="Table1" runat="server">
</table>
and using code behind to write cells, rows and server controls into the
cells doesn't work ( can't programactially access a table )

I am currently trying to do:

<table id="Table1" runat="server">
<tr><td><asp:placeHolder id="PL1"/></td></tr>
<tr><td><asp:placeHolder id="PL2"/></td></tr>
</table>

and in code behind

protected System.Web.UI.WebControls.PlaceHolder PL1;
protected System.Web.UI.WebControls.PlaceHolder PL2;

and then wanting to write a server control to each placeholder and then
be
able to read and write information to the server controls. But I am
unable
to reference the newly created server controls.

Actually, it is not a big problem to create a cell and a control in
it.

Instead of PlaceHolders, try following

// create first row
HtmlTableRow r1 = new HtmlTableRow();
HtmlTableCell c1 = new HtmlTableCell();
r1.Cells.Add(c1);

// create second row
HtmlTableRow r2 = new HtmlTableRow();
HtmlTableCell c2 = new HtmlTableCell();
r2.Cells.Add(c2);

Table1.Rows.Add(r1);
Table1.Rows.Add(r2);

// then you can add a control, e.g.

TextBox txt = new TextBox();
txt.ID = "mytext";
r1.Cells[1].Controls.Add(txt);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top