Solved

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

Posted on 2012-12-26
2
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
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…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

739 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