473,378 Members | 1,396 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,378 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 3668
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...
1
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.