TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jose Saiz
1.5k
260
103.3k
HOW To Add script to the end of the ASP.NET page
Mar 31 2020 12:54 PM
Help on adding script to the end of the ASP.NET page after the HTML </body> tag from code behind
Default.aspx
<%@ Page Language=
"C#"
AutoEventWireup=
"true"
CodeFile=
"Default.aspx.cs"
Inherits=
"Default_Page"
%>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head runat=
"server"
>
<title>Testing</title>
</head>
<body>
<form id=
"form1"
runat=
"server"
>
<div>
<p><input type=
"button"
id=
"myjs"
value=
"Click"
/></p>
</div>
</form>
</body>
<!-- Insertted Script should go here after inserted from Code behind -->
</html>
I would like to add this script or any other script after the </body> tag and before </html> tag from the behind code
<script>
document.getElementById(
"myjs"
).addEventListener(
'click'
, function () {
alert(
"Hello World"
);
});
Is the above possible?
I tried this from code behind
//- Quick and dirty script string to make my question clear
string
MY_SCRIPT_STRING =
"<script>alert('Hello Word')</script>"
;
this
.Controls.Add(
new
LiteralControl(MY_SCRIPT_STRING));
This works but it adds the code inside the form not at the end of the page where I want the script code to go after the HTML Tag
</body> and before </html>
TIA
Reply
Answers (
3
)
Updating identity table aspnetuser in mvc web application
How to Make inspinia chart based on chart.js dynamic in mvc5