Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i am using webuser controle in that page i wrote one javascript funtion for text box ,then how to call that javascript function in another aspx page .

like for example:

SampleWebusercontrole.ascx in that page
---------------------------------------------------------------------------
XML
<script type="text/javascript">
 function QuantityChange()
 {
   //our Code
 }
</script>



<asp:textbox id="txtquantity" runat="server" onchange="QuantityChange()"/>
---------------------------------------------------------------------------------

sample.aspx
-------------------------------------------------------------------------------

in this page i want use that javascript function

how to call that javascript function in sample.aspx not in sample.aspx.cs
pls help me....

---------------------------------------------------------------------------
Posted
Updated 11-Feb-15 19:52pm
v2

You should place all your global functions,variable etc in a .js file and then on all pages that need to call any of these routines you should declare it like this

JavaScript
<script src="myglobals.js" type="text/javascript"></script>


Now you can access your global functions and variables.Happy Coding
 
Share this answer
 
Comments
Member 10776340 12-Feb-15 2:13am    
ok but how to get the id's of webusercontrole of all controls in myglobals.js

pls sir send sample code ...
Try using...
HTML
parent.QuantityChange()

If you access any .js function from other page use "parent" to access that function.

Hope this will help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900