Link to home
Start Free TrialLog in
Avatar of dmullis
dmullisFlag for United States of America

asked on

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

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.
Avatar of mmarinov
mmarinov

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

Regards!
B..M
are you trying to access a routine in the control?
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.
Avatar of dmullis

ASKER

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.
Man, I don't think it is possible
ascx files are something like the #include directive in the old asp , so ...

B..M
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;
    submit();
  }
</script>

Then on the serverside use: string s = Request.Form["xfer"];
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());
Avatar of dmullis

ASKER

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'>"
+"</a>"


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?
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial