.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Javascript at the end of aspx files. What is the benefit?

Posted By:      Posted Date: August 29, 2010    Points: 0   Category :ASP.Net
Hello,In one of the examples I saw a call to a JS function at the end of the aspx file.Like the following:<script language="javascript" type="text/javascript">   <!--    SetExternal();   // --></script>I was under the impression that the JS functions are either called on onlclick of button events or in the HTML Body tag with Onload.So when an aspx page loads then do you thin the following function which is at the end of the page will be called? and why do we put these functions at the end of the page?Thanks.

View Complete Post

More Related Resource Links

How to use GZIP for aspx, css, and javascript files.

Hi all,I have heard that if we use gzip, aspx files will be loading faster. But, I am not sure as to how to use it in my web applications.I am hosting my site with GODADDY (ASP 2, IIS 7)Can anyone tell me if I will be able to use gzip? Can you give me a sample file where gzip is used?Thanking you in advanceTomy

Combine, minify and compress JavaScript files to load ASP.NET pages faster

Websites are getting more interactive these days and most of this interactivity comes from JavaScript. People are using different JavaScript libraries and frameworks to make their websites more interactive and user friendly.

>>>How to use javascript function in aspx file?



I have a file util.js and there some funtions in same file.

For example functions name are keyUp, keyDown, isNumeric, isAlphaNumeric

I have used these functions in aspx code behind in a textbox to restrict user that he may not be able to input any special character.

Before, I used the code directly in aspx file but I have do it for different textboxes therefore to avoid much coding in aspx file I created util.js and put all code in this file but how to use these particular functions in aspx file I couldn't find the way.

Anyone have idea. Do share with me.

I used the reference like this:


' Font-Names="Verdana" Font-Size="8pt" Onkeyup= "keyUp(event.keyCode)" Onkeydown="return isAlphaNumeric(event.keyCode);" onpaste="return false;">

jqGrid with WebMethods in aspx.cs files



here is my code for jqgrid:

/// <reference path="jquery-1.3.2.js" />
/// <reference path="json2.js" />
/// <reference path="jquery.simplemodal.js" />
$(document).ready(function() {

jpg files will not display in gridview on aspx page

I have an image object in a template of a gridview The datasource of the image object evaluates to the path of the jpg file. However, the aspx page displays a little red x instead of the picture. How do I get the image to display/Frank learning vs 2005

calling a javascript function within aspx

i have a js method i wrote myself called sumAlert();  i want to call it in my aspx like this, when a user clicks on a button<asp:Button ID="Button" runat="server" Text="Submit" OnClientClick="if (confirm('WARNING! You will be unable to save again if you proceed')) sumAlert();"                        OnClick="Button_Click" />How can i get it to call the function if the user confirms OK?

modify/override properties of default sharepoint modal dialogs (ex. editview.aspx) using javascript

Hello all, I would like to know how can I modify (override) some properties of the default sharepoint modal dialogs using Javascript. Ex. the size and location of editview.aspx. I while ago I asked a question about overriding the DialogResult in the display view dialog. I got an answer from Zach which looked like this:             sb.Append("<script type=\"text/javascript\">");             sb.Append(@"window.setTimeout(function () {");             sb.Append(@"if (window.frameElement && typeof(window.frameElement.overrideDialogResult) == 'function')");             sb.Append(@"{");             sb.Append(@"SP.SOD.executeFunc('sp.ui.dialog.js', 'SP.UI.DialogResult.OK', function () {");             sb.Append(@"window.frameElement.overrideDialogResult(SP.UI.DialogResult.OK); ");             sb.Append(@"});");             sb.Append(@"}");  

Access Javascript from an aspx file through another aspx file

Hello, So.. I have a file called myFile.aspx which is linked to a js file called myJS.js    There is a file linked to an entirely different frame called theOtherFile.aspx.  I want to access a function is myJS.js called myFunc in theOtherFile.aspxI am not entirely sure how I would accomplish that..I am quite new to MVC2 and JS, so I am quite confused as to how to do this.  Any suggestions would be much appreciated.~Anath

remove upload multiple files link from upload.aspx..

hi, is there a way to remove the upload multiple files link from upload.aspx..without using any custom coding.

Adding JavaScript to Default.aspx


Hi there,

I am relatively new to SharePoint Designer and want to add a piece of JavaScript code that I have used before on standard HTML websites but I am not 100% sure where to put the code on the page.

I tried already and got an error so I have removed the code and the page works as standard.

Below is the code I inserted to a webpartzone (right) replacing the &nbsp; which was already there.

<script type="text/javascript">
//new fadeshow(IMAGES_ARRAY_NAME, slideshow_width, slideshow_height, borderwidth, delay, pause (0=no, 1=yes), optionalRandomOrder)
new fadeshow(fadeimages, 300, 220, 0, 7000, 1)

The main script is very long so I hadnt pasted it in but i placed it at the top of the page (when in code view). Here it is below:

What am i doing wrong?

The Commish

<script type="text/javascript"> 
* Ultimate Fade-In Slideshow (v1.5): © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages[0]=["images/rotate01.jpg", "", "

Capture query string value in javascript in aspx page


I have a simple problem that I cannot remember how to solve.  I am sure it is very easy.  Following is my code:

<asp:Image id="btnAddNew" runat="server" ImageUrl="~/images/btnAdd.png" OnClick="javascript:window.open('DetailLocation.aspx?projectID=&locationID=','newWindow','width=600,height=600,scrollbars=yes');" />

In the OnClick event I have embeded a javascript function that works as expected. However, I need to embed a querystring value into the javascript function variable:


I thought I could just embed <%=Request("projectID") %> in there, but the compiler does not like it. 

Thanks in Advance.



Hide the empty rows on dispform.aspx using javascript


Guys, can I hide the empty rows on display form using javascript?

If you know anything, Help me.


Too many javascript files loading?


I recently ran yslow on a page i have (master paged etc) and it returned that there were far too many javascript files included (most of which I haven't added).

I guess my question is that given i have v1.0.20229.0 of the toolkit.dll (over .net 2)

I'm wondering if subsequent releases have fixes for this sort of thing?


how can i Register multi javascript files with RegisterClientScriptInclude method in OnPreRender


hi friends.

how can i use multi javascript files with RegisterClientScriptInclude method in custom server controls.

when i call two or more  RegisterClientScriptInclude method, this method registers only one of the javascript files.

protected override void OnPreRender(EventArgs e)
            string testJS = Page.ClientScript.GetWebResourceUrl(this.GetType(), "MyControl.js.testJS.js");
            string RichText = Page.ClientScript.GetWebResourceUrl(this.GetType(), "MyControl.js.RichText.js");
            this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "MyControl", testJS);
            this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "MyControl",RichText); 

i registered javascript files in AssemblyInfo.cs like this :

[assembly: WebResource("MyControl.js.RichText.js", "text/javascript")]
[assembly: WebResource("MyControl.js.testJS.js", "text/javascript")]

Dynamic compilation of aspx-files stopped working!



I recently ran into some strange problems. Changes to files that are not code-behind (and not gets compiled to a DLL) should not require you to recompile the whole website, and this has never been I problem for me. These should actually get compiled dynamically when you first access the resource, e.g. the first time when browsing an updated aspx-page in the browser. 

But yesterday, during development of a website, I noticed that even the smallest changes in html, javascript or anything in the .aspx-files doesn't get reflected when I save and reload the page in my browser. Rebuilding doesn't help either, actually I'll have to do a "Rebuild All" (in Visual Studio 2008) in order to see the changes. This applies to all aspx-files in my project.

I tried with minor changes on files in another web application project on the same server, and there it works as it should. Something must has happened to this particular application, but I cannot figure out what.
Do you have any ideas on how to solve this?

Best regards

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend