Solved

Display ASP.Net Tables (markup) from VB.Net (code behind) through ASP Literal in PassThrough

Posted on 2012-12-26
2
338 Views
Last Modified: 2013-01-09
I would like to dynamically create ASP tables using VB to dynamically populate the data and provide unique IDs and then assign it to a Literal in Passthrough mode.

How can I go about qualifying my code with quotation marks around ASP parameters and having VB.Net accept/concatinate my string properly?  I know the vb is being triggered because I also have a label change.

Sample of my code:
htmlText = "<asp:TableRow ID=""TR1C" & intC.ToString() & """>"

CraneTables.Text = htmlText.ToString()

(In the ASP page)
<asp:Literal ID="CraneTables" Mode="PassThrough" EnableViewState="false" runat="server"></asp:Literal>

Open in new window


I'm not an expert in ASP, so if there is a better way for me to do this can you please provide some examples.  I am trying to keep it all in the code behind because I will also be pulling in data from multiple MS SQL queries and have Create/Update/Delete tied into it.

Thank you.
0
Comment
Question by:quistlogic
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 38722615
This:

htmlText = "<asp:TableRow ID=""TR1C" & intC.ToString() & """>"

Open in new window


...is not going to work. You cannot create server-side controls via a string. Such controls need to be present in the markup at the time the view engine runs. Aside from that, your approach seems complicated. Why not just create a table in your code-behind?

e.g.

Code-behind
Dim t As New Table()
Dim r As New TableRow()
Dim c As New TableCell()

c.Text = "Hello World!"
r.Cells.Add(c)
t.Rows.Add(r)
t.ID = "TR1C" + i.ToString()
Me.placeholder1.Controls.Add(t)

Open in new window


Markup
<asp:Placehodler ID="placeholder1" runat="server"></asp:Placeholder>

Open in new window

0
 
LVL 2

Author Closing Comment

by:quistlogic
ID: 38761132
This is a great way to display data and control it.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question