473,624 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

asp.net equivalent of <% response.write( "") %>

Hi,
I have the following in my asp page:

<% response.write( Header) %>

where Header contains HTML markup such ass <html> <body> ....

I must write the code in the aspx file and not in the code behind so
that the markup are generated at correct places in html stream.

I've tried :

<script runat=server>
response.write( Header)
</script>

but that wouldn't work. How can i do it ?

Thank you.

Feb 23 '06 #1
7 2706
You should be able to do it in the same way as you do it now with <%
response.write( Header) %>.
The script section you tried should also work, even though I've never
used it myself as I always use the <% %>, if I have to code something
in the aspx file.
So maybe the problem is that you are not getting the Header right,
where are you getting the Header from?

Feb 23 '06 #2
Yes I know I can do it with <% %> and it works fine actually.
But I was told this is not good to do this in asp.net anymore.
I should use the <script> markup but if I do then it wouldn't work for
some reason. :(

Feb 23 '06 #3
It's not good to do that in .net anymore????
Who told you that?
It's the same thing as doing it on the script block.

Feb 28 '06 #4
I've read that in a book that using <% %> in the aspx page instead of
<script/> is not good. It is obsolete...

Mar 1 '06 #5
I never heard that before, but well if you don't want to use <% %>
which works, then I think that you would have to use a control that
parses the html and place it exactly where you want the html to be
placed (if that's even possible, because I never had to do this).
Because it seems that if you want to use the script block, the Response
object, or any other for that matter need to be written under any
method or property.
I think, if it fits your need you should go with what works for your
solution, no matter how "obsolete" it is. And if it's obsolete how come
directives still use the <% %>.
Notice that I'm not encouraging the use of <% %> in any way. But in
your particular case, that's the best way to go. In any other case,
where you just want to write something into a page, is better to use
controls and place it under their corresponding property.

HTH

Mar 1 '06 #6
You should avoid the <% %> construct any more because it doesn't conform
with the ASP.NET programming model. There are instances within controls
like Repeater and DataList where it is appropriate to use <%# %> when you're
trying to add database table values to a control. But to use the <%= %>
construct that is from classic ASP is no longer appropriate with the new
programming model. Look at the MSDN documentation for more information.
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

<sa************ *@googlemail.co m> wrote in message
news:11******** **************@ z34g2000cwc.goo glegroups.com.. .
Hi,
I have the following in my asp page:

<% response.write( Header) %>

where Header contains HTML markup such ass <html> <body> ....

I must write the code in the aspx file and not in the code behind so
that the markup are generated at correct places in html stream.

I've tried :

<script runat=server>
response.write( Header)
</script>

but that wouldn't work. How can i do it ?

Thank you.

Mar 2 '06 #7
><sa*********** **@googlemail.c om> wrote in message
news:11******* *************** @z34g2000cwc.go oglegroups.com. ..
Hi,
I have the following in my asp page:

<% response.write( Header) %>

where Header contains HTML markup such ass <html> <body> ....
We discussed this already in another thread. It was pointed out to you
that this isn't a good idea. You shouldn't store the HTML in the
database, rather store the attributes (eg page title, meta description,
etc) in the database and populate server controls.
I must write the code in the aspx file and not in the code behind so
that the markup are generated at correct places in html stream.
That doesn't make sense. Populating in the aspx file does not give you
any more control over where the HTML is generated, and it mixes code
with presentation. Code-behind gives you full control over where the
HTML (or any other content) is placed.

You are thinking in a classic ASP way, and that is hindering your
attempts.

Furthermore, as already explained, this will *not* allow you to mark the
HTML you're writing as runat="server" anyway, so your attempts to use
themes with such a header will simply not work, no matter how many times
you ask the question.
I've tried :

<script runat=server>
response.write( Header)
</script>

but that wouldn't work. How can i do it ?


You could read the suggestions you've already been given. What you show
above will definitely work, it will insert the HTML at the specified
place. However, having a Literal control in the aspx file and setting
its Text property in the code-behind works just as well, but has major
advantages of separating the code from the presentation.

For example, if your HTML in the aspx file looks like this...

<head runat="server">
<title><asp:Lit eral id=litTitle" runat="server" /></title>
</head>

then you can set the title of the page from code-behind *and* have
themes working.

--
Alan Silver
(anything added below this line is nothing to do with me)
Mar 2 '06 #8

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

Similar topics

5
2793
by: Eric A. Forgy | last post by:
Hello, I am just learning Java and am trying to write a method that does something like //=========================================== public Static List find(double array,double val,String relationalOp) { List list = new ArrayList();
1
6819
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
7
2086
by: Diandian Zhang | last post by:
Does anyone have an idea, how to do it? Thanks in advance!
16
1933
by: rik | last post by:
I was flicking through a PHP book (one of the teach in 24 hour ones) and I came across something I had never seen before in PHP. It was a method of printing out without using the print method, it was something like : <?= $myVar; ?> Is this an out dated method? Is it compatible with all versions of PHP (since implementation at least)?
4
2009
by: | last post by:
Hello NG! Within a xsl-stylesheet I have an element <xsl:text><!]></xsl:text> If I use that stylesheet to transform some xml-data (to html) with .... pOut = New System.IO.StringWriter
2
6836
by: andrew007 | last post by:
I do xml / xslt transformation using asp.net but I found any value (w/xml format) in xml node html-encoded to &lt and &gt format if it's > or < tag. Since I have sub xml data in a parent xml node as a value. Check out the following problem. I want to convert the value in <WpDatesXml> node to have a valid "<" and ">" instead of &lt or &gt format so that I can use this xml for another use. Please help! <NewDataSet> <Table1>
3
1982
by: Manish Sawjiani | last post by:
Dear experts i have just migrated from asp to asp.net and i am missing the loop for creating tables. while in asp one could just start a loop anywhere withing <% %is this out of style in the .Net Scenario? Thanks Manish --
3
2166
by: Steven.Xu | last post by:
hi everybody, i am useing some classes which in System.Xml to deal with xml document. what can i do if the document include "<" or ">"? Thanks.
1
4308
by: ismailc | last post by:
Hi, I need help please. Update system to to new version & moved on to .Net2 But now my code that worked in my .Net1 xslt does not work. .Net1 fine: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:asp="remove" xmlns:igchart="remove" xmlns:igsch="remove"> &lt;td class='rowDet' id="td_<xsl:value-of select='@name' />"&gt; .Net2 don't work: <xsl:stylesheet...
0
8175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7168
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6111
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2610
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1487
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.