Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesRazor + Page Object + Script InsertionRazor + Page Object + Script Insertion
Previous
 
Next
New Post
2/7/2011 1:59 PM
 
I am trying to figure out a way to add my razor modules script (js) file to the current page's header in a way that will check if it exists, only insert it once, etc.

The "old school" reference on how to do this in webforms is found here:  http://www.dotnetnuke.com/Resources/F...

However, not having access to the page lifecycle or the page object for that matter makes this difficult.

It seems like this should be easy, but I have pounded my head against the wall long enough, time to bow to the experts.

Thanks in advance.
 
New Post
2/10/2011 9:05 AM
 
Razor requires scripts to be in cshtml or vbhtml , not js. If you take a look at the video at http://channel9.msdn.com/Shows/Web+Camps+TV/CodeMash-2011-WebMatrix-Launch-Keynote (about minute 21 on) you'll see demo's of how to add razor in a DotNetNuke install.

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
2/10/2011 9:45 AM
 
I understand that and have a working cshtml file, inherited layouts, etc.

I am simply trying to add a js file that the module uses to the header of the page, and do so uniquely so if multiple copies of the module are dropped on the page it doesn't get loaded with unnecessary script references.

As you can see in my original post I link to the article on how to accomplish this with webforms.
 
New Post
2/11/2011 10:52 AM
 
if it's just a js file then you can either add it to the skin (so it's available on every page), or add it to the default.aspx.vb (using the webforms code to check if it's registered and if not add it to the page) - however, rather than that I'd recommend you either create a simple module which you add to all pages (or else a httphandler) or consider a solution such as Will Strohl's inject module - http://www.willstrohl.com/Blog/EntryId/341/WillStrohl-Injection-Module-for-DotNetNuke-Explained

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
2/11/2011 11:27 AM
 
1.  Add it to the skin:  Makes the module dependent on the skin, thus not easily deployable.
2.  default.aspx.vb:  Core modification, no way, no how, for obvious reasons.
3.  simple module:  Makes the module dependent on another module, which adds more overhead than just duplicating the script.
4.  Will Strohl:  Same as #3, just that the module is written for me already.

I am really looking for a way to do this through Razor, which I have a feeling is going to involve extending the helper classes.  I am just wondering if anybody else has done the research/work yet since I haven't had the time.  I also have the feeling this is going to involve more than just extending the helper since Razor modules inherit DotNetNukeWebPage, but once again, I haven't traced the source back far enough to see if that is just an extension of WebPage that can also be overridden/added to.

I did look through most of the hackathon entries also, which are just placing the scripts inline, thus duplicating them if placed on the page more than once.

Either way I think this is something fairly core/basic for most future razor modules to have the capability of doing.  I will just have to put my razor attempts to the side until it is more mature or I have more time to dig through the source, whichever comes first.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesRazor + Page Object + Script InsertionRazor + Page Object + Script Insertion


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out