ASP.net : Master page Javascript function not firing from every content page
A sample of folders in my web application is as follows:
MyApplicationName
--> MasterPages/MasterPage1.aspx --> Reports/Clients/ARReports.aspx --> AboutUs/CompanyInfo.aspx --> Javascript/General.jsI have added Print ImageButton to Master page MasterPage1.aspx. It has a JavaScript function onClientClick event:
<asp:ImageButton ID="imgbtnPrint" runat="server"
ImageUrl开发者_开发技巧="~/images/icons/print.gif"
AlternateText="Print" OnClientClick='javascript:PrintContent("printable");this.blur();return false;' />
 Print  
The PrintContent function is in General.js file.
CompanyInfo.aspx and ARReports.aspx both have Masterpagefile = MasterPage1. Now the issue is that the Print ImageButton in CompanyInfo.aspx is able to call the JavaScript function when clicked. However, in ARReports.aspx no JavaScript function is fired when clicked.
What could be the problem? The ImageButton is in Master page which refers to the JavaScript file which has the JS function. It is working for CompanyInfo.aspx, but if we go deep inside the folders, it is not working.
Is it possible you're not including General.js in your master page but ARE in CompanyInfo.aspx?
Can you show us where (in what file) and how (syntax) you're including General.js?
In Page Load I add the JavaScript file dynamically, so that all pages can access it with ResolveUrl
Page.Header.Controls.Add(CreateJavaScriptLink("~/javascript/General.js"));
精彩评论