in Education by
i have a control that is organized like this and i want to have the javascript registered on the calling master pages, etc, so that anywhere this control folder is dropped and then registered, it will know how to find the URL to the js. Here is what i have so far (in the user control ) protected void Page_Load(object sender, EventArgs e) { if(!Page.IsClientScriptBlockRegistered("jqModal")) Page.ClientScript.RegisterClientScriptInclude("jqModal", ResolveClientUrl("~js/jqModal.js")); if (!Page.IsClientScriptBlockRegistered("jQuery")) Page.ClientScript.RegisterClientScriptInclude("jQuery", ResolveClientUrl("~/js/jQuery.js")); if (!Page.IsClientScriptBlockRegistered("tellAFriend")) Page.ClientScript.RegisterClientScriptInclude("tellAFriend", ResolveClientUrl("js/tellAFriend.js")); } Any ideas? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You can use a helper class with static method: public static class PageHelper { public static void RegisterClientScriptIfNeeded( Page page, string key, string url ) { if( false == page.IsClientScriptBlockRegistered( key )) { page.ClientScript.RegisterClientScriptInclude( key , ResolveClientUrl( url )); } } } or you can have a similar instance method in some base class for page/webcontrol/usercontrol, which will do the same thing.

Related questions

0 votes
    i have a control that is organized like this and i want to have the javascript registered on the calling ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    I am trying to set text and value for both td tag and input tag at the same time. But after ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I am trying to set text and value for both td tag and input tag at the same time. But after ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    What I'm trying to do: when an element with any class listed in an array is clicked, the class ( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    What I'm trying to do: when an element with any class listed in an array is clicked, the class ( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    What I'm trying to do: when an element with any class listed in an array is clicked, the class ( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    What I'm trying to do: when an element with any class listed in an array is clicked, the class ( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I am paginating users and in my view I have: I want to limit li.profile to 200 characters ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 11, 2022 in Education by JackTerrance
0 votes
    When I use ajax call from a modal window, the request url seems not correct. I have a webserver ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: jQuery in Greasemonkey 1.0 conflicts with websites using jQuery (3 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I'm trying to capture the event of opening and closing the bootstrap accordion, but with the typescript the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    We are planning to use the jQuery library to augment our client side JavaScript needs. Are there any major ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 25, 2022 in Education by JackTerrance
0 votes
    I have a google map and is not displayed properly. To see what I'm talking about check this LINK ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    I'm trying to make an event listener for when a button is 'active' (has an .active class in my ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I'm trying to make an event listener for when a button is 'active' (has an .active class in my ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
...