Is it possible to call an ascx page with a javascript function?

Posted on 2004-10-15
Medium Priority
Last Modified: 2008-03-10
Is it possible to call an ascx page with a javascript function?

I have a footer that a programmer created in C#. The ascx page has HTML + javascripts on it. The code behing page has some C# on it.
Question by:dmullis
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +3
LVL 28

Expert Comment

ID: 12319242
Hi dmullis,

so what do you mean by "call an ascx page with a javascript function" ?
you can drag & drop the ascx file on your aspx page and when you open the page in browse you will see the result of executed ascx file

LVL 17

Expert Comment

ID: 12319399
are you trying to access a routine in the control?
LVL 25

Expert Comment

ID: 12319962
Please explain your question in detail. To add the footer decalre the following at the top of your aspx page:

<%@ Register TagPrefix="MYWeb" TagName="Footer" Src="Footer.ascx"%>

and where you want to insert the footer, add the following lines:

<MYWeb:Footer id="Footer" runat="Server"></MYWeb:Footer>

HTH, Nauman.

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Author Comment

ID: 12320203
I am not using an aspx page..that would be easy. I hate to get into the details of this because it confuses everyone and the general issue but here goes:

I have an xml page created by other programmers..I cannot "re-do" this some other way. In the xml page, it contains several pages with page ids and their specific elements like textboxes, etc. From these page id's I can call a javascript function such as onclick, onload, etc. Within each of these page ids,at the beginning of the page, there are numerous javascript functions called by the elements. I will have to use a javascript function to call the footer that resides on the ascx page..This xml page will not understand putting
 <%@ Register TagPrefix="MYWeb" TagName="Footer" Src="Footer.ascx"%> at the top of each page id.

I plan to put an onload event with each page id element..( I know how to do this in the XML. I know how to position the footer on each page id.). The onload event should call a javascript function that calls my ascx page. I need to know if javascript can call an ascx page and if this is possible,how to tell the javascript function to call the ascx page.
LVL 28

Expert Comment

ID: 12320265
Man, I don't think it is possible
ascx files are something like the #include directive in the old asp , so ...


Expert Comment

ID: 12325663
hmm, im not quite sure if i understand your question, but if you are trying to get javascript to interact with aspx you can do something like the following:

<input type=hidden id=xfer name=xfer />
<script language=javascript>
  function foo()
    document.forms[0].xfer.value = something;

Then on the serverside use: string s = Request.Form["xfer"];

Expert Comment

ID: 12325666
you can then have the server interpret that and do something to a
<asp:PlaceHolder Runat=server ID="PlaceHolder1"></asp:PlaceHolder>
PlaceHolder1.Controls.Add(new Footer_ascx.Footer());

Author Comment

ID: 12380807
I wound up having to create a server control and do it this way, because of the deadline.

+"<td width='103'><a href='../pages/ContactUs.aspx' onMouseOut='MM_swapImgRestore()'"
+"onMouseOver='MM_swapImage('Contact US','','../images/controls/footer/contact_on.gif' ,1)'>"
+"<img name='Contact US' border='0' src='../images/controls/footer/contact_off.gif' width='119' height='43'>"

I appreciate all your input.
nitogenx..you answered my other question about putting the javascript inside the above.

 Not sure what to do about points here. Moderater?

Accepted Solution

modulo earned 0 total points
ID: 12734852
PAQed with points refunded (500)

Community Support Moderator

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question