Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Scenario:

I have an ASPX page with multiple ASCX control. 1 of ascx control contain a dropdown list with selected value, it will prompt up a ajax pop-up message with data using javascript(main function=call pop up and close pop up message)and vb.net code(bind data source).

I have replicate the exactly the same stuff into other ascx, i am able to get it done by using different div id in UI and different function name in javascript.

The problem is i could not use back the same div id in UI, and javascript.

I have search through google but could not found anythings regarding it.

The question is possible to call same javascipt function in other ascx under same aspx page.if yes, what should i check for?

sorry i could not reveal the code due to financial sensitivity.
Posted

Hi,

yeah you can maintain single javascript function for multiple ascx files

but you've to maintain different ids for controls used in ascx control


ASP.NET
    <uc1:webusercontrol id="WebUserControl1" runat="server" xmlns:uc1="#unknown" />
    <br />
    <uc2:webusercontrol2 id="WebUserControl21" runat="server" xmlns:uc2="#unknown" />
<input type ="button" id="btnpage1" value ="testingoncontrol1" onclick ="showmypop(this.id)" />


Here i'm providing some example for using same javascript function in different ascx files

HTML
code under Wenusercontrol1
  <input type ="button" id="btnpage2" value ="testingoncontrol2" onclick ="showmypop(this.id)" />

HTML
code under Wenusercontrol2
  <input type ="button" id="btnpage3" value ="testingoncontrol3" onclick ="showmypop(this.id)" />


And finally the javascript method must be exists in aspx page

HTML
aspx script file contains following method
     function showmypop(tid) {
            alert(document.getElementById(tid).value);
        }



I hope you understood what I said.

all the Best.
 
Share this answer
 
Thanks for the nice guideline.
 
Share this answer
 
Comments
Muralikrishna8811 27-Sep-11 4:17am    
you r welcome

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



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