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

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

Access Javascript from an aspx file through another aspx file

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :ASP.Net
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

View Complete Post

More Related Resource Links

>>>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;">

How to use the following aspx file to access mysql database


The following code is named default.aspx  in a sms gateway, The purpose of this file is to split the incoming message [using split function in C#] and store the the messages into string array,

We query a mysql database for the words in string array . and return the queried fields [time] from the [source] and [destination]  into the message.

Should we include the namespaces in the aspx file? 

Please check what is wrong with the following code.

<%@ Page Language="C#"%>
    using MySql.Data.MySqlClient;
    using System;

    string MyConString = "SERVER=localhost;" +
				"DATABASE=sample;" +
				"UID=root;" +
	MySqlConnection connection = new MySqlConnection(MyConString);

string sender = Request.QueryString["sender"];
string receiver = Request.QueryString["receiver"];
string messagedata = Request.QueryString["messagedata"];
string messageid = Request.QueryString["messageid"];
string messagetype = Request.QueryString["messagetype"];
string senttime = Request.QueryString["senttime"];
string receivedtime = Request.QueryString["receivedtime"];
string service

Deny anonymous access for single .aspx file


I have a folder called /Error in the root directory for an ASP.Net site.  The site is completely public, so there is no authentication of users.  Inside the Error folder, I have a file called errorlog.aspx, where I log unhandled exceptions.  I don't want the public to be able to view this file.  I created a web.config file inside the Error folder.

<?xml version="1.0"?>
	<location path="errorlog.aspx">
				<deny users="?"/>

However, I'm still able to view errorlog.aspx by typing the URL into the browser.  What am I missing?



Launch CMD File From ASPX Page


My organization uses a CMD file to install updated files for a major enterprise application. Currently, we send out an email to users with a link to the file and instructions to run it, BUT inevitably users don't update their machines until their in field and try to start the app.


We're now liking the idea of using an ASPX page to prompt the users to run the updates and to capture the fact that the updates have been run. I realize that we can't capture the success or failure of the update. But we'd like to capture the user accessed the page.


Is it possible to embed into the markup for the page a link to the file on the local intranet that the users can click on to run the file?

The user accessing the page would capture that they did just that. We'd deal with wether or not the update was actually installed or if it failed later with them directly.

Calling parameterized method from aspx file


Hi all,
I have following method
 public string GetYoutubeVideo (string code)
        return "asasdasfa"

Linking JS file to ASPX page or content page

Hi, I moved my JS functions into an external file "JScript.js", because I'm now using a master page and a content page.But it doesn't work any more, and I can't find why.I tried simply to link a js file to an ASPX file, by adding to the script manager the path of my script, but it doesn't work.Here is my js file (we don't need any special things in it do we?) var step1 = false; function pageLoad() { var accCtrl = $find('AccordionCtrl_AccordionExtender'); accCtrl.add_selectedIndexChanged(onAccordionPaneChanged); } function hideAccordionPane(paneNo) { ... } function changeSelected(idx) { ... } function onAccordionPaneChanged(sender, eventArgs) { ... } function check() { ... }And here is my ASP code: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0

How to change the split view when editing an aspx file

I've been using SPD 2010 more and more over the past few weeks.  However, when there's a navigation bar on the left, toolbox on the right, ribbon above and split view of code and design in the middle, there's just not enough room on the screen - (I have 2 LCDs at 1280x1024).  I can spread the window accross both monitors but that's not much use unless, I can change the split between code and design from horizontal to vertical. Is this possible?  Help apprieciated. Cheers, Bill

Changes in the values of controls of .cs file not reflecting on .aspx webpage while execution.

In my code I am assigning certain values to labels from data reader.While debugging I can see that proper values are assigned but the changes are not reflecting in the end of debug on the webpage that are executing.// My Code// Question.aspx.csusing System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;public partial class Examinee_Question : System.Web.UI.Page{    ExamFunctions ef = new ExamFunctions();    SqlConnection con,con1;    SqlCommand cmd,cmd1;    SqlDataReader dr,dr1;    String QType="";    int ctr = 1;    protected void Page_Init(object sender, EventArgs e)    {        con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Db.mdf;Integrated Security=True;User Instance=True");        con.Open();        con1 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Db.mdf;Integrated Security=True;User Instance=True&qu

Help with vb-based aspx file from scratch


Hey, newbie here.

I am making a website from scratch. I know nothing about asp.net, but I want to learn to use it for it's database interoperability. So far, everything I've done has been basic html.

I have SOME experience with VB. I decided to make an aspx  page alone from scratch that was vb based, and all I'd done so far was create a form  in web developer 2010 express.

My html page is cut up into frames, and i tried src'ing one of them to the aspx page. But when I run the frames.html page, the part that's supposed to show the aspx page is showin me this:

The XML page cannot be displayed

Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.

A name was started with an invalid character. Error processing resource 'file:///C:/Users/xxxxxxx/Desktop/xxxxxx/NewCa...

<%@ Page Language="VB" %>


I don't know what this means. This was the html code given to me when I created the aspx page. So why doesn't it understand it?

Another thing I couldn't find was the vb code page for the aspx while I was working on it IN web develope

url rewrite for images(.jpg file extension not .aspx)



I have stored DB images. and I try to access images using url rewrite. But it is not happaning.

I tried this scott methord. http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx. i tried with Application_BeginRequest, but no use

Basically Client don't want to use .aspx extension for images

Is it possible acess db images with out using .aspx file name extension?  then can anybody tell me how to achieve this!!!!!!!!!!!!

My sample url is "www.sample.com/images/folder/imagefilename.jpg" I want to rewrite to "www.sample.com/images/pimges/default.aspx?file=imagefilename.jpg&cat=folder"



Setup file(*.msi) also includes .aspx.cs (source code) files also


My project is recently migrated from 2008 to 2010

actualy we developed project in VS 2005 in that we created setup file but when we migrated to vs2008 setup file giving problem to us.

now when we make setup file it is including .aspx.cs files also but this if we publish our project it wont including source code.

why setup file including .aspx.cs files is there any way to change.

plz replay ASAP

Adding a server control on aspx page does not add events in aspx.designer.vb file



I work in VS 2008. Whenver I add a server control(Label) and set it properties in aspx.vb and build the solution, I get the error "Label1 not declared". While analyzing this issue I noticed that the event handler statements for the Label1 where not added in the designer.asp.vb file. These statement would actually be added automatically when I drag and drop a control to my webpage.

I would also like to inform the scenario after which this problem came to me. I was working in VS 2008 , VS 2005 and VS 2003 in the same machine.Could this have caused the issue ? Please advise.

Now each and everytime when I add a control, I am adding the "With Events" code in the designer page to make my build succesfull which makes me to spend more efforts.

Please advise if any settings have to be changed.



Downloading an xml file in Web App is of type .aspx



Ive created a Web App where it is possible to download an xml file from the server to the client. It works just fine except that the Save Dialog recognizes the file being dowloaded as of type .aspx and the name of the file as being the name of the page I'm on. The page is called Download.aspx and it contains a button that when clicked executes the following code:

                //sends the content to the client
                Response.ContentType = "text/xml;charset=utf-8";
                Response.AppendHeader("Content-Disposition", "attachment, filename=questionnaire.xml");

The save dialog appears and says:

Name: Download.aspx

Type: ASP.NET Server Page, 1,16KB


If I download the file and open it it contains the correct Xml file content and nothing else, so it is working correctly. It just annoys me that it appears to the user that he is downloading the aspx site (and it shows up as such in windows explorer as well) rather than the xml file which is the actual content.

Does anyone know how I can get the save dialog to show the name and type of my xml file rather than the web page?

Using vb function in ..aspx file


i have this line of code:

<li><a href="/TrainingOptions.aspx?pageID=<%#UrlEncode("Online Training") %>">

but it does not encode and my urls are pageID=(blank)

please help. is it even possible without having to do it via backend in a literal?

to point to .aspx file located in a different folder



I have an iframe in one of my aspx files which is located in folder1. 

I have a line of code in my page iframe1.Attributes.Add("src","filename.aspx");

The filename.aspx file is in folder2, so the above line throws an error.....

The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

Requested URL: /folder1/filename.aspx

so, its basically looking for the filename.aspx only in folder1, how can I make it point to the other folder. I tried iframe1.Attributes.Add("src","folder2/filename.aspx"), but its of no use.

Any help would be greatly appreciated.

Thanks in advance.


.cs file not in sync with .aspx


Whenever I add a CheckboxList control to my page in design view, I'm not seeing the corresponding protected variable that the form designer automatically adds in the .cs file. 

Also, I can't find the OnInit method and InitializeComponent methods in my .cs file. I don't think I deleted them. How to restore this page in proper order ? How could have they disappeared?

 I'm using the AJAX Extensions/ .Net 2.0 / VS 2005 / developing on XP Professional / IIS on a Windows 2000

 Thanks all.

How to change the content of an html file using an aspx file?


Hi everyone,

I would really like to have a little help, it should be easy but i can't find the answer

and it's been a while since iv'e done something with asp.net..

what i have now is a regular html pages website.

in some of the pages i have galleries,

I would like to make an aspx page to manage the content of the galleries or any other set-in advance content.

It's kind of a CMS, but it's not, since i would not be using a database.

what i want is just to get the admin's content from the aspx page

and send it to overwrite the images or the content of the DIVS in the html page.

at the final outcome, i will only want to have html files and one aspx file for the admin's editing use.

what is the most simple way to do that without using CMS? 

Thanks a bunch!


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