Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > asp.net equivalent of <% response.write("") %>

Reply
Thread Tools

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

 
 
samuelberthelot@googlemail.com
Guest
Posts: n/a
 
      02-23-2006
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.

 
Reply With Quote
 
 
 
 
Hugo Flores
Guest
Posts: n/a
 
      02-23-2006
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?

 
Reply With Quote
 
 
 
 
samuelberthelot@googlemail.com
Guest
Posts: n/a
 
      02-23-2006
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.

 
Reply With Quote
 
Hugo Flores
Guest
Posts: n/a
 
      02-28-2006
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.

 
Reply With Quote
 
samuelberthelot@googlemail.com
Guest
Posts: n/a
 
      03-01-2006
I've read that in a book that using <% %> in the aspx page instead of
<script/> is not good. It is obsolete...

 
Reply With Quote
 
Hugo Flores
Guest
Posts: n/a
 
      03-01-2006
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

 
Reply With Quote
 
Christopher Reed
Guest
Posts: n/a
 
      03-02-2006
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."

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.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.
>



 
Reply With Quote
 
Alan Silver
Guest
Posts: n/a
 
      03-02-2006
><(E-Mail Removed)> wrote in message
>news:(E-Mail Removed) roups.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:Literal 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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Warning:Xst:382 - Register A is equivalent to B mag VHDL 1 05-19-2005 05:10 PM
instancename of current entity/architecture -- equivalent to C++ this??? Eric Peers VHDL 2 11-18-2004 05:23 PM
VHDL equivalent of verilog trireg Sanjeev VHDL 4 07-23-2004 09:55 AM
equivalent types in different packages Lolo VHDL 3 09-22-2003 03:23 PM
Re: Image Scanning - TWAIN equivalent Brendan Duffy ASP .Net 0 07-24-2003 08:29 AM



Advertisments