473,395 Members | 1,521 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

generating a .js file with asp.net

WL
Hi,

I'm trying to build an .ASPX file that returns the contents of a .js file,
so that I can use:

<script language="JavaScript" src="/mypage.aspx"
type="text/javascript"></script>

Even when disabling viewstate etc I still end up with ASP.NET returning
contents as set with
Response.Write("var test=12;") in the PageOnLoad I end up with this extra
HTML code:

Thanks,

Wim

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>page4</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form method="post" action="page4.aspx" id="Form1">
<div>
<input type="hidden" name="__VIEWSTATE"
value="/wEPDwUKLTUxMTcwNzgxMGRkPbcvOzDy6UopR2KGJnAsry/0lgY=" />
</div>

</form>
</body>
</HTML>
Nov 18 '05 #1
5 1386
2 ways to get rid of that, that I can think of:

1) Remove all that stuff from the .aspx doing the generation. So leave only
the @Page directive. Since all that stuff is there in the .aspx, it
automatically becomes part of the response.
2) Try a Response.Clear before your .aspx starts Response.Write'ing its
javascript contents.

"WL" <no****@nospam.nospam> wrote in message
news:ez*************@tk2msftngp13.phx.gbl...
Hi,

I'm trying to build an .ASPX file that returns the contents of a .js file,
so that I can use:

<script language="JavaScript" src="/mypage.aspx"
type="text/javascript"></script>

Even when disabling viewstate etc I still end up with ASP.NET returning
contents as set with
Response.Write("var test=12;") in the PageOnLoad I end up with this extra
HTML code:

Thanks,

Wim

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>page4</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form method="post" action="page4.aspx" id="Form1">
<div>
<input type="hidden" name="__VIEWSTATE"
value="/wEPDwUKLTUxMTcwNzgxMGRkPbcvOzDy6UopR2KGJnAsry/0lgY=" />
</div>

</form>
</body>
</HTML>

Nov 18 '05 #2
WL
Response.Clear does not work because the ASP.NET stuff is added AFTERWARDs.
Meanwhile I found I out you can do this in the page.obload, after having set
the response.content:

Response.End()

Wim

"Marina" <so*****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
2 ways to get rid of that, that I can think of:

1) Remove all that stuff from the .aspx doing the generation. So leave only the @Page directive. Since all that stuff is there in the .aspx, it
automatically becomes part of the response.
2) Try a Response.Clear before your .aspx starts Response.Write'ing its
javascript contents.

"WL" <no****@nospam.nospam> wrote in message
news:ez*************@tk2msftngp13.phx.gbl...
Hi,

I'm trying to build an .ASPX file that returns the contents of a .js file, so that I can use:

<script language="JavaScript" src="/mypage.aspx"
type="text/javascript"></script>

Even when disabling viewstate etc I still end up with ASP.NET returning
contents as set with
Response.Write("var test=12;") in the PageOnLoad I end up with this extra HTML code:

Thanks,

Wim

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>page4</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form method="post" action="page4.aspx" id="Form1">
<div>
<input type="hidden" name="__VIEWSTATE"
value="/wEPDwUKLTUxMTcwNzgxMGRkPbcvOzDy6UopR2KGJnAsry/0lgY=" />
</div>

</form>
</body>
</HTML>


Nov 18 '05 #3
Ok yes, good point, you would not need to clear what was already there - but
only make sure that nothing else got written out.

"WL" <no****@nospam.nospam> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Response.Clear does not work because the ASP.NET stuff is added AFTERWARDs. Meanwhile I found I out you can do this in the page.obload, after having set the response.content:

Response.End()

Wim

"Marina" <so*****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
2 ways to get rid of that, that I can think of:

1) Remove all that stuff from the .aspx doing the generation. So leave

only
the @Page directive. Since all that stuff is there in the .aspx, it
automatically becomes part of the response.
2) Try a Response.Clear before your .aspx starts Response.Write'ing its
javascript contents.

"WL" <no****@nospam.nospam> wrote in message
news:ez*************@tk2msftngp13.phx.gbl...
Hi,

I'm trying to build an .ASPX file that returns the contents of a .js file, so that I can use:

<script language="JavaScript" src="/mypage.aspx"
type="text/javascript"></script>

Even when disabling viewstate etc I still end up with ASP.NET returning contents as set with
Response.Write("var test=12;") in the PageOnLoad I end up with this extra HTML code:

Thanks,

Wim

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>page4</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form method="post" action="page4.aspx" id="Form1">
<div>
<input type="hidden" name="__VIEWSTATE"
value="/wEPDwUKLTUxMTcwNzgxMGRkPbcvOzDy6UopR2KGJnAsry/0lgY=" />
</div>

</form>
</body>
</HTML>



Nov 18 '05 #4
WL
Marina,

I just found it: how stupid of me: really your option 1 is the solution. I
was so much under the impression of Dotnet generating all kind of code for
me automatically that I forgot that the code I wanted to get rid of was just
inside my .aspx file.

My sincere apologies for my stupidity ;-)

Wim
"Marina" <so*****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
2 ways to get rid of that, that I can think of:

1) Remove all that stuff from the .aspx doing the generation. So leave only the @Page directive. Since all that stuff is there in the .aspx, it
automatically becomes part of the response.
2) Try a Response.Clear before your .aspx starts Response.Write'ing its
javascript contents.

"WL" <no****@nospam.nospam> wrote in message
news:ez*************@tk2msftngp13.phx.gbl...
Hi,

I'm trying to build an .ASPX file that returns the contents of a .js file, so that I can use:

<script language="JavaScript" src="/mypage.aspx"
type="text/javascript"></script>

Even when disabling viewstate etc I still end up with ASP.NET returning
contents as set with
Response.Write("var test=12;") in the PageOnLoad I end up with this extra HTML code:

Thanks,

Wim

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>page4</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form method="post" action="page4.aspx" id="Form1">
<div>
<input type="hidden" name="__VIEWSTATE"
value="/wEPDwUKLTUxMTcwNzgxMGRkPbcvOzDy6UopR2KGJnAsry/0lgY=" />
</div>

</form>
</body>
</HTML>


Nov 18 '05 #5

I do this frequently in my code. In fact, I dynamically generate my
includes and reference them that way.

What you do is clear everything in your aspx file except the page directive.
Then, in the code behind, add the following line:

Response.AddHeader("text/javascript");
.... // emit the script
Response.End();
That should do.

Thanks,
Shawn
http://www.zenofdotnet.com

"WL" <no****@nospam.nospam> wrote in message
news:ez*************@tk2msftngp13.phx.gbl...
Hi,

I'm trying to build an .ASPX file that returns the contents of a .js file,
so that I can use:

<script language="JavaScript" src="/mypage.aspx"
type="text/javascript"></script>

Even when disabling viewstate etc I still end up with ASP.NET returning
contents as set with
Response.Write("var test=12;") in the PageOnLoad I end up with this extra
HTML code:

Thanks,

Wim

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>page4</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form method="post" action="page4.aspx" id="Form1">
<div>
<input type="hidden" name="__VIEWSTATE"
value="/wEPDwUKLTUxMTcwNzgxMGRkPbcvOzDy6UopR2KGJnAsry/0lgY=" />
</div>

</form>
</body>
</HTML>

Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: daniele.balducci | last post by:
Hi All, I'm generating XLS files from ASP(.Net) code using the usual code chunks ... Response.ContentType = "application/vnd.ms-excel" Response.AppendHeader("Content-Disposition", "attachment;...
0
by: manas589 | last post by:
Hi Can any one tell me how to use binding.xml while generating castor bean from an xsd file. i have one xsd file where two element are conflicting. so i thought to use binding file while...
1
by: Nathan Sokalski | last post by:
Visual Studio 2005 recently stopped generating the *.designer.vb files for my *.aspx and *.ascx files. I am using Service Pack 1, and do not believe I did anything differently than normal prior to...
1
by: csharpula csharp | last post by:
Hello, I need to generate cs files from XSD files. I would like to do it automatically. What is the best way to do it? Is it better be done with PreBuild inside VS (before compilation) or to...
0
by: nuttynibbles | last post by:
hi, im creating a mobile apps whereby if i transfer a file from a PC to a folder directory in the windows mobile phone, it will detect and fire an event? for example, rename each file that is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.