Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

HT make screens morf to fit the current situation?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
xzzy - 23 Jun 2007 17:56 GMT
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.
Alexey Smirnov - 23 Jun 2007 22:43 GMT
> 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.
[quoted text clipped - 19 lines]
> 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);
xzzy - 24 Jun 2007 15:34 GMT
the problem is: after the viewer adds/changes information in the textbox,
how to reference the information in the textbox

>> I am stuck on how to make a screen whose fields are created at runtime so
>> it
[quoted text clipped - 46 lines]
> txt.ID = "mytext";
> r1.Cells[1].Controls.Add(txt);
Alexey Smirnov - 24 Jun 2007 20:01 GMT
> the problem is: after the viewer adds/changes information in the textbox,
> how to reference the information in the textbox

you would need an EventHandler

HOW TO: Dynamically Create Controls in ASP.NET by Using Visual C# .NET
http://support.microsoft.com/kb/317794

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.