Here's one for you. I was developing a module. Said module needed to register Javascript. I did this:
modPath = this.ModulePath;
if (!Page.ClientScript.IsClientScriptIncludeRegistered("calendarDateInput"))
{
Page.ClientScript.RegisterClientScriptInclude("calendarDateInput", modPath + "calendarDateInput.js");
}
This worked. I went home. I came back in. NOW it changed behavior. If I was logged in with a role with Edit capabilities on the page, the Javascript was registered correctly, and the module submit button worked and everything was cool. If I wasn't logged in, or was logged in as a user without Edit capabilities, not only was my JS not registered, but clicking the submit button wouldn't even work. This, of course left me confused.
Viewing source, I noticed a difference in the generated names of elements on the page based on being logged in, and not being logged in with an Edit role. Logged in, I'd see names like this:
name="dnn$ctr380$ViewOpenBook$OB_Search"
and NOT logged in or without edit:
name="dnn$ctr380$ViewOpenBook$ViewOpenBook$OB_Search"
Odd. Something was saying "Caching problem" to me, so I cleared my browser cache: no go. I cleared my DNN cache: no go. I tried turning OFF DNN Cache: no go. All of my code was the same as the functioning code before, and so I double checked it. All good. I saw there was a cache setting in manifest which was set to 60. I changed this to 0. Still no good. Finally, I deleted the module definition from DNN, and then reimported it.
Now when I add my module to a page everything is working again.
My question is WHY DID THIS HAPPEN, AND WHY DID THIS FIX IT? (Caps just to emphasize my actual question after all that setup)
=====
As an aside, I have two questions about best practices:
Is the way I am getting the path of the module the best way? (modPath = this.ModulePath)
What all is supposed to be in the manifest file? IE should my CSS and Javascript files be listed, and images, and all that?
Any help is appreciated. I am asking this question because should this occur in a production environment, it would be a huge problem and I want to make sure I know WHY it happened so I can prevent it in the future if this is only a matter of me being stupid somehow.
Michael