Solved

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

Posted on 2012-12-26
2
332 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 74

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now