?
Solved

Response.Write text *after* </html>

Posted on 2005-05-04
7
Medium Priority
?
232 Views
Last Modified: 2010-04-07
I am using ASP.NET with CodeBehind VB.

I need to programatically write some values to the VERY end of the html document, after the </html> tag.

When I use Response.Write (in the Page_Load Sub) it prints the text at the top.

I also tried adding a label after the </html> and updating it's Text property, but that didn't work becuase the text I'm trying to add is actually JavaScript...and it doesn't like being put inside a <span> or <div> tag.

With Classic ASP I could just Response.Write the text where I wanted it. Is there a way to do this with ASP.NET?
0
Comment
Question by:CodeManiac
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 12

Expert Comment

by:laotzi2000
ID: 13933236
You can add
<% Response.Write(...) %>
after </html>, like in asp
0
 
LVL 12

Expert Comment

by:laotzi2000
ID: 13933243
and your whole structure like this:

in .aspx.vb
public class ...
public str as string

sub page_Load(...)
  str = something
end sub

in .aspx
<% Response.Write(str) %>
0
 
LVL 23

Accepted Solution

by:
b1xml2 earned 2000 total points
ID: 13933258
after html, add the following control:
<asp:Literal Id="MyLiteral" Runat="server" />

this control does not have to be inside a HtmlForm control.

Thus, MyLiteral.Text = "blah blah"
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 26

Expert Comment

by:Rejojohny
ID: 13933326
>>becuase the text I'm trying to add is actually JavaScript

use Page.RegisterStartupScript Method ..
this method emits the script just before the closing tag of the Page object's <form runat= server> element. that should be </form>

isn't this what u want ?
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 13933785
Rejojohny,

you are mistaken, the RegisterStartupScript method puts the script at the beginning,
ref: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIPageClassRegisterStartupScriptTopic.asp

it's the RegisterClientScriptBlock that puts it just before the end of the form.

0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 13933942
i had looked it up from MSDN installed in my PC and just verified it again ...
this is what it says and I think the same must be mentioned in the site too ...

Page.RegisterClientScriptBlock
Allows ASP.NET server controls to emit client-side script blocks in the Page.
The client-side script is emitted "just after the opening tag of the Page" object's <form runat= server> element. The script block is emitted as the object that renders the output is defined, so you must include both tags of the <script> element.

Page.RegisterStartupScript Method
Allows ASP.NET server controls to emit client-side script blocks in the Page.
Similar to the RegisterClientScriptBlock method, this method emits the script "just before the closing tag of the Page" object's <form runat= server> element. The script block is emitted as the object that renders the page is defined, so you must include both tags of the <script> element.


0
 
LVL 1

Author Comment

by:CodeManiac
ID: 13934746
Thanks, that was exactly what I was looking for.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

807 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