Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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..
Reply With Quote
  #2 (permalink)  
Old March 21st, 2010, 11:22 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
  #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..
Reply With Quote
  #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#
Reply With Quote
  #5 (permalink)  
Old March 22nd, 2010, 02:57 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
  #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#
Reply With Quote
  #7 (permalink)  
Old March 22nd, 2010, 03:46 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
  #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#
Reply With Quote
  #9 (permalink)  
Old March 22nd, 2010, 05:26 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
  #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#
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:49 PM.


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