Wednesday, 15 May 2013

c# - How to place this java script function in an external file for user control? -



c# - How to place this java script function in an external file for user control? -

i have user command called header.aspx. in user command if work.

<script type="text/javascript"> function greeting(){ alert("hi"); } </script> <asp:button id="button1" onclientclick="greeting" /> </asp:button>

i using user command in page called default.aspx. tried using src="~scripts/foo.js". if not work. question pretty simple guess. how phone call java script function in user command stored in external location( not in page. located in scripts folder). in advance.

as can understand path issue. follow these steps might help you.

create .js file first. set code , save in folder want to. now drag , drop js file within head section of html code solution explorer window. give right path js file.

the above steps follow, when create external js file controls.

also create sure phone call function in manner suggested others else function won't call:

<asp:button id="button1" onclientclick="greeting();" /> </asp:button>

c# javascript asp.net

No comments:

Post a Comment