473,320 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Injecting html

Hi All

I am making a particular asp.net page using the codebehind method. What I
need to do is write out html in the code behind into a specific place in the
page. Somewhat like the way Servlets work.

I have a couple of questions I hope someone can help with:

1. Can I output html by doing something like Response.out.write("<b>"); and
is this the best way to do it
2. How can I add some sort of placeholder for where I want to inject the
html?

I should also add that I don't want to use the other asp.net mechanism that
doesnt use code behinds

Thanks everyone.

Simon
Nov 18 '05 #1
3 3666
the best way i have found to do this is to use a Label. set the text
property to whatever you want the html to be on that part of the page.

lblExample.Text = "<b>";

<asp:Label ID="lblExample" runat="server"/>

"Simon Harvey" <si**********@the-web-works.co.uk> wrote in message
news:u5**************@TK2MSFTNGP10.phx.gbl...
Hi All

I am making a particular asp.net page using the codebehind method. What I
need to do is write out html in the code behind into a specific place in the page. Somewhat like the way Servlets work.

I have a couple of questions I hope someone can help with:

1. Can I output html by doing something like Response.out.write("<b>"); and is this the best way to do it
2. How can I add some sort of placeholder for where I want to inject the
html?

I should also add that I don't want to use the other asp.net mechanism that doesnt use code behinds

Thanks everyone.

Simon

Nov 18 '05 #2
Placeholder is the best bet. You can then output literal controls
(LiteralControl class) and attach them to the placeholder. I like the panel,
which creates a <span> in HTML.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Simon Harvey" <si**********@the-web-works.co.uk> wrote in message
news:u5**************@TK2MSFTNGP10.phx.gbl...
Hi All

I am making a particular asp.net page using the codebehind method. What I
need to do is write out html in the code behind into a specific place in the page. Somewhat like the way Servlets work.

I have a couple of questions I hope someone can help with:

1. Can I output html by doing something like Response.out.write("<b>"); and is this the best way to do it
2. How can I add some sort of placeholder for where I want to inject the
html?

I should also add that I don't want to use the other asp.net mechanism that doesnt use code behinds

Thanks everyone.

Simon

Nov 18 '05 #3
You can use something like this:

<=%BuildHTML%>
</body>

Where BuildHTML is defined in your codebehind as:

Protected Function BuildHTML() as String

"Simon Harvey" <si**********@the-web-works.co.uk> wrote in message
news:u5**************@TK2MSFTNGP10.phx.gbl...
Hi All

I am making a particular asp.net page using the codebehind method. What I
need to do is write out html in the code behind into a specific place in the page. Somewhat like the way Servlets work.

I have a couple of questions I hope someone can help with:

1. Can I output html by doing something like Response.out.write("<b>"); and is this the best way to do it
2. How can I add some sort of placeholder for where I want to inject the
html?

I should also add that I don't want to use the other asp.net mechanism that doesnt use code behinds

Thanks everyone.

Simon

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jamie R. Parent | last post by:
Hello, How do you go about taking a variable which was declared in C and pass that through to a Python script? I have tried doing this by adding a simple string which is a PyObject from C into...
17
by: George Sakkis | last post by:
Is there a general way of injecting code into a function, typically before and/or after the existing code ? I know that for most purposes, an OO solution, such as the template pattern, is a cleaner...
0
by: Peter Rilling | last post by:
Although an ADODB question, I am using C#, so here I go. I am trying to use the ADODB Stream object to extract content from a body part of an MHTML formatted document. I can save the raw...
5
by: Nadav | last post by:
Hi, Introduction: ************************************************************ I am working on a project that should encrypt PE files ( Portable executable ), this require me to inject some...
3
by: Simon Harvey | last post by:
Hi All I am making a particular asp.net page using the codebehind method. What I need to do is write out html in the code behind into a specific place in the page. Somewhat like the way Servlets...
17
by: Luke Matuszewski | last post by:
Hi ! Simple question (but thus it may appear no simple answer): If i putting a script onto the page i simply could inline it in <script> element or via its src attribute so (second way): <script...
9
by: tai | last post by:
Hi. I'm looking for a way to define a function that's only effective inside specified function. Featurewise, here's what I want to do: bar_plugin_func = function() { ...; setTimeout(...);...
14
by: ofiras | last post by:
Hii everyone, I'm a web programmer, but I never understood sql injecting. All I found was that you can write "a' or 'a'='a" in the password field to try to connect without knowing the password. I...
1
by: rh.krish | last post by:
Hi, I have a unique situation. We have many applications (approx - 20) built on .NET framework 1.1 & 2.0 and hosted in one single IIS website in PROD. We have similar setup in TEST. Now we want to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.