Unable to include javascript from script.js file

Posted by Murugavelmsc under C# on 2/5/2014 | Points: 10 | Views : 646 | Status : [Member] | Replies : 4
Hi All,

I'm unable to use scripts off of the script.js file. Even if I put in a simple function as follows:

function ShowAlert()
{
alert('Hi');

return true;
}

doesn't show the alert popup! If I include the same in the web form's aspx code, it works just fine. Any ideas?

version - VS 2010


Thanks,
Murugavel S

Regards,
Murugavel S
murugavel.sadagopan@gmail.com
http://murugavelmsc.blogspot.in/



Responses

Posted by: Sravan661 on: 2/5/2014 [Member] Bronze | Points: 25

Up
0
Down
Hi,
Please include the reference of the script.js in your WebPage or MasterPage in Head section as follows
 <script src="~/Scripts/script.js " type="text/javascript"></script>


Hope this helps you
Revert if you have any issues . . .

sravan

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: kgovindarao523-21772 on: 2/5/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

Include your reference by dragging it to your master page or current content page, and call it in an event like button click.
<input type="button" value="Call Me" onclick="javascript:ShowAlert()">

Please Mark as Answer if you satisfied


Thank you,
Govind

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Murugavelmsc on: 2/5/2014 [Member] Starter | Points: 25

Up
0
Down
Hi Guys,

I am already done the reference in the aspx page its not working. But place the js code into the aspx page it works fine.

Hope you guys got it.


Thanks,
Murugavel S


Regards,
Murugavel S
murugavel.sadagopan@gmail.com
http://murugavelmsc.blogspot.in/

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sravan661 on: 2/6/2014 [Member] Bronze | Points: 25

Up
0
Down
can u please paste your code

sravan

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response