473,404 Members | 2,195 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,404 software developers and data experts.

Using an ASPX file as a Script Source

I recently came across an application where the 'src' attribute of a
script tag was an ASPX file. Like so:

<script language="JavaScript" src="scriptfile.aspx"></script>

This is a new idea for me, and I had some questions about it.

When scriptfile.aspx is processed, is it going to have access to the
same request object and submitted form variables that the parent page
has? Will that aspx page be able to access the public and protected
members with <% %server tags as the parent page would?

And maybe someone can link me to a guide on the web that details what
can and can't be done in this situation.

Thanks.

Aug 22 '06 #1
5 4400
If you are going to emit Javascript from an ASPX page, you will need to
remove everything in the ASPX (Html page) portion except the <@page
declaration at the top.
In your Page_Load EventHandler, that is where you would
Response.Write the string of script.

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Moskie" wrote:
I recently came across an application where the 'src' attribute of a
script tag was an ASPX file. Like so:

<script language="JavaScript" src="scriptfile.aspx"></script>

This is a new idea for me, and I had some questions about it.

When scriptfile.aspx is processed, is it going to have access to the
same request object and submitted form variables that the parent page
has? Will that aspx page be able to access the public and protected
members with <% %server tags as the parent page would?

And maybe someone can link me to a guide on the web that details what
can and can't be done in this situation.

Thanks.

Aug 22 '06 #2
Hi,

Peter Bromberg [C# MVP] wrote:
If you are going to emit Javascript from an ASPX page, you will need to
remove everything in the ASPX (Html page) portion except the <@page
declaration at the top.
In your Page_Load EventHandler, that is where you would
Response.Write the string of script.
And also set the Response.ContentType to "text/javascript" ?

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 22 '06 #3
That much I understand.

My questions are pertaining to what I actually have access to when that
aspx page is processing (i.e. in the Page_Load handler). Do I have
access to the same Requset object as the parent page (the page with the
script tag)? Or is this going to be a whole new request with a whole
new request object?

My gut tells me that this is going to be whole new request, and I have
no way to "pass" anything to it when it is being requested via a script
tag.... unless ASP.Net is doing something weird that I'm not aware of.

Peter wrote:
If you are going to emit Javascript from an ASPX page, you will need to
remove everything in the ASPX (Html page) portion except the <@page
declaration at the top.
In your Page_Load EventHandler, that is where you would
Response.Write the string of script.

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Moskie" wrote:
I recently came across an application where the 'src' attribute of a
script tag was an ASPX file. Like so:

<script language="JavaScript" src="scriptfile.aspx"></script>

This is a new idea for me, and I had some questions about it.

When scriptfile.aspx is processed, is it going to have access to the
same request object and submitted form variables that the parent page
has? Will that aspx page be able to access the public and protected
members with <% %server tags as the parent page would?

And maybe someone can link me to a guide on the web that details what
can and can't be done in this situation.

Thanks.
Aug 22 '06 #4
My gut tells me that this is going to be whole new request, and I have
no way to "pass" anything to it when it is being requested via a script
tag.... unless ASP.Net is doing something weird that I'm not aware of.

Your gut is right - the browser sends a new request to get the
javascript file. You *could* store bits in session and process them when
the request comes back in but this seems like a horrible kludge to me,

Moskie wrote:
That much I understand.

My questions are pertaining to what I actually have access to when that
aspx page is processing (i.e. in the Page_Load handler). Do I have
access to the same Requset object as the parent page (the page with the
script tag)? Or is this going to be a whole new request with a whole
new request object?

My gut tells me that this is going to be whole new request, and I have
no way to "pass" anything to it when it is being requested via a script
tag.... unless ASP.Net is doing something weird that I'm not aware of.

Peter wrote:
>If you are going to emit Javascript from an ASPX page, you will need to
remove everything in the ASPX (Html page) portion except the <@page
declaration at the top.
In your Page_Load EventHandler, that is where you would
Response.Write the string of script.

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Moskie" wrote:
>>I recently came across an application where the 'src' attribute of a
script tag was an ASPX file. Like so:

<script language="JavaScript" src="scriptfile.aspx"></script>

This is a new idea for me, and I had some questions about it.

When scriptfile.aspx is processed, is it going to have access to the
same request object and submitted form variables that the parent page
has? Will that aspx page be able to access the public and protected
members with <% %server tags as the parent page would?

And maybe someone can link me to a guide on the web that details what
can and can't be done in this situation.

Thanks.

Aug 22 '06 #5
Moskie wrote:

<snip>
My gut tells me that this is going to be whole new request, and I have
no way to "pass" anything to it when it is being requested via a script
tag.... unless ASP.Net is doing something weird that I'm not aware of.
Why not use a query string to "pass" parameters to the ASPX page
generating the script file?

<script type="text/javascript"
src="scriptfile.aspx?param1=value1&param2=value2"> </script>

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 22 '06 #6

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

Similar topics

0
by: Niyazi | last post by:
Hi all, This my aspx page first line of code. <%@ Page CodeBehind="index.aspx.vb" Language="vb" AutoEventWireup="false" Inherits="TB.index" %> Than inside head tag I have following script(s)...
4
by: Bart de Vries | last post by:
Hello, I new on developing with ASP.NET and i wrote some lines of code. This works fine when all the code is in one page, but when i split it up into and ASPX file and make an DLL using a...
0
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
2
by: Ric | last post by:
im new to asp.net. from what i understand, you have the aspx file (presentation), user-control(ascx file), code-behind(vb file) and components(compiled vb and dll files). the aspx file contains a...
5
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
14
by: Mark B | last post by:
Our webhost (www.usbusinessweb.net) had a W2K IIS5 server crash after a scheduled hard-boot occurred during a ms-security patch install overnight. They couldn't get the server working again so they...
10
by: bienwell | last post by:
Hi, I have a question about file included in ASP.NET. I have a file that includes all the Sub functions (e.g FileFunct.vb). One of the functions in this file is : Sub TestFunct(ByVal...
13
by: Bob Jones | last post by:
Here is my situation: I have an aspx file stored in a resource file. All of the C# code is written inline via <script runat="server"tags. Let's call this page B. I also have page A that contains...
7
by: JeremyWoertink | last post by:
I have an app that I need to make changes to, and on my local copy I have a start.aspx.vb file that I edited and tested, now when I go to the app on the server, it doesn't show any of the .vb...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.