Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
| Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 21st, 2010, 10:47 AM
Authorized User
Points: 437, Level: 7
Points: 437, Level: 7 Points: 437, Level: 7 Points: 437, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2008
Location: Tareem, Hadramout, Yemen.
Posts: 89
Thanks: 13
Thanked 0 Times in 0 Posts
Question How to appear Html tags in .aspx page when run it

Code:
document.write("<html><body> msman88 </body></html>");
The above code is in default.aspx page, and I need to import it in a javascript as an external file as below,
Code:
<script type="text/javascript" src="http://localhost:49718/uu1/Default2.aspx"></script>
But when I run the page default.aspx, I get follows only:
Code:
document.write("msman88");
the problem I wnat to solve is to to make html tags displayed on the page when running it, and the page should display code exactly like the 1st code above, and do not want html tags to be executed by browser..

Hint:
1) Previously, I used to use HtmlEncode() in c#, but problem I faced that the output is not a valid javascript code.
2) Now I shifted to make the code is static on an aspx page, but the problem is still facing us here, that html tags are also executed by the browser when running the page.
After that I solved it by putting the html tags inside <xmp> tag as follows:
<xmp>
Code:
<xmp>document.write("<html><body> msman88 </body></html>");</xmp>
That made the output is containing html tags and they are not executed by browser, but I still I face the same problem, the <xmp> made the output is not a valid javascript.
__________________
ASP.NET & C#

Last edited by msman88; March 22nd, 2010 at 05:19 PM..
  #2 (permalink)  
Old March 21st, 2010, 11:22 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Didn't we do this here: Problem with "HttpUtility.HtmlEncode()"

Anyway, again, you're not proving enough information. What's the purpose of this code / exercise? What other content does Default2 contain? Does it just output this code or does it output an entire page? Where exactly did you place the link / script tag to Default2.aspx? And what's the point of document writing am <html> element when you are already inside an <html> element with a <script> child element?

And finally, it's not clear what the actual problem is. What do you mean with:

Quote:
But when I run the page default.aspx, I get follows only:

Code:
document.write("msman88");
That doesn't make a whole lot of sense. HTML elements don't get stripped from source code automatically, so I am pretty sure the tags are still there, but you just don't see them. Explain us how you run this page, what you input where, and what output you see and where and we may be able to help you.

And didn't the previous thread put you in the right direction?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #3 (permalink)  
Old March 21st, 2010, 11:51 AM
Friend of Wrox
 
Join Date: Dec 2008
Location: , , .
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
Default

For that file you tried to import, it should be coded as a javascript file, not a aspx file. Hope this clean things up and make it easier for you. Something like the following:

Code:
<html>
<head>
	<script type="text/javascript" src="apple.js"></script>
</head>
<body onload="apple();">
</body>
</html>
Here is what's in apple.js:
Code:
function apple() {
	alert("apple");
}
Based on what we talked in last thread, I guess maybe you have the need to make your javascript slightly different from time to time based on certain conditions. maybe that's why you used aspx to generate it. Actually to do that, there is still no need to dynamically generate the .js file, what you can do is:
1) Make your javascript functions taking parameters; (make it 100% static content)
2) In your calling web page, pass in the parameters. (this one has dynamic content any way, to pass parameter to js should not be a big deal)

Hope this helps.

Last edited by PeterPeiGuo; March 21st, 2010 at 12:02 PM..
  #4 (permalink)  
Old March 21st, 2010, 02:38 PM
Authorized User
Points: 437, Level: 7
Points: 437, Level: 7 Points: 437, Level: 7 Points: 437, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2008
Location: Tareem, Hadramout, Yemen.
Posts: 89
Thanks: 13
Thanked 0 Times in 0 Posts
Default

I found it, see

Code:
<xmp>document.write("<html><body> msman88 </body></html>");</xmp>

But a problem what I have, that code became is not valid a javascript more.
so what's still needed?
__________________
ASP.NET & C#
  #5 (permalink)  
Old March 22nd, 2010, 02:57 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
so what's still needed?
What about an answer to the many questions I asked? There are many ways to do what you're doing, but you need to know the scenario in order to pick the right solution.

Just posting a snippet of code with a "But a problem what I have, that code became is not valid a javascript more." is not enough. You need to *explain* what you're trying to accomplish.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #6 (permalink)  
Old March 22nd, 2010, 03:44 PM
Authorized User
Points: 437, Level: 7
Points: 437, Level: 7 Points: 437, Level: 7 Points: 437, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2008
Location: Tareem, Hadramout, Yemen.
Posts: 89
Thanks: 13
Thanked 0 Times in 0 Posts
Default

what should I add more on the code to make it is a valid javascript more ?
__________________
ASP.NET & C#
  #7 (permalink)  
Old March 22nd, 2010, 03:46 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Why do you refuse to answer the questions that need to be answered in order to answer yours?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #8 (permalink)  
Old March 22nd, 2010, 05:20 PM
Authorized User
Points: 437, Level: 7
Points: 437, Level: 7 Points: 437, Level: 7 Points: 437, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2008
Location: Tareem, Hadramout, Yemen.
Posts: 89
Thanks: 13
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Imar View Post
Why do you refuse to answer the questions that need to be answered in order to answer yours?

Imar
i edited the original topic. you can understand well now.
__________________
ASP.NET & C#
  #9 (permalink)  
Old March 22nd, 2010, 05:26 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I don't.

I still don't know what code the page outputs, how it does it, what other code it contains (e.g. whether it clears the response and only emits JavaScript or the JavaScript is mixed with the rest of the page). I don't uderstand the final purpose of all this, and I don't know exactly what you want to accomplish.

Why do you only post tiny snippets of your code without explaining how things fit together and where you call what? tell us how things are related to each other. And so on and so forth.

So, by all means, play hide and seek and make this as hard as you want. But if you want help, be clear, concise,and describe what it is that you want as detailed as possible.

Cheers

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #10 (permalink)  
Old March 22nd, 2010, 05:36 PM
Authorized User
Points: 437, Level: 7
Points: 437, Level: 7 Points: 437, Level: 7 Points: 437, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2008
Location: Tareem, Hadramout, Yemen.
Posts: 89
Thanks: 13
Thanked 0 Times in 0 Posts
Default

I got tired, and any thing is clear.
please try this out:
1)
create an html page, and include following in it:
Code:
<html><body><xmp>document.write("<hmtl><body> msman88 </body></hmtl>");<xmp></body></hmtl>
I need <xmp>, but it made the code is not a javascript any more, when calling the page inside a javascript code.
so what is to make it a valid javascript code and with existence of <xmp>

cheers!
__________________
ASP.NET & C#




Similar Threads
Thread Thread Starter Forum Replies Last Post
Hiding meta-tags in aspx page reach_reema ASP.NET 2.0 Basics 0 September 10th, 2008 01:49 AM
html(aspx) web page sivkum Javascript 1 January 11th, 2007 01:53 AM
convert Html in aspx page prashantraizada2002 ASP.NET 1.0 and 1.1 Basics 1 June 24th, 2006 04:55 PM
Add XSLT transformed XML (html) on an aspx page humour XSLT 2 September 30th, 2004 05:13 AM
Cookie Error when run web page test.aspx C#.net minhpx General .NET 1 August 10th, 2004 01:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.