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...DNN Platform (o...DNN Platform (o...Module Absolute PathModule Absolute Path
Previous
 
Next
New Post
8/11/2009 5:26 PM
 

I need to register a client script and the script must be an absolute path.. so in my control I need to understand how to point directly to the /scripts path inside my module installation directory.

 

So if my site was at http://www.mydomain.com I need to know how to generate the path

http://www.mydomain.com/DesktopModules/myModule/Scripts

But the kicker is I need to ensure I am using the alias that is currently in use...

I am thinking I will use

HttpContext.Current.Request.Url

but this seems a bit odd... any better way to do this?

 
New Post
8/11/2009 5:59 PM
 

 

 

 

 

Better said I am trying to end up with this on my page... (from my control) - where the path is obviously unique for the install.

<script type="text/javascript">var GB_ROOT_DIR = "http://training.dev/DesktopModules/myModule/greybox/";</script>
<script type="text/javascript" src="http://training.dev/DesktopModules/myModule/greybox/AJS.js"></script>
<script type="text/javascript" src="http://training.dev/DesktopModules/myModule/greybox/AJS_fx.js"></script>
<script type="text/javascript" src="http://training.dev/DesktopModules/myModule/greybox/gb_scripts.js"></script>
<link href="http://training.dev/DesktopModules/myModule/greybox/gb_styles.css"" rel="stylesheet" type="text/css">

How to get here?

 

 
New Post
8/13/2009 1:54 PM
 

This is all I could come up with for how to render an absolute path to a folder in my module directory.. please advise if there is something better I should be doing.

 

    Public Function getControlPath(ByVal controlBase As String) As String
        Dim protocol As String = "http://"
        If Left(Request.ServerVariables("SERVER_PROTOCOL"), 5).ToLower = "https" Then
            protocol = "https://"
        End If
        Return protocol + Request.ServerVariables("SERVER_NAME") + controlBase
    End Function

 

I use it like this..

 

        csname = "gb_scripts"
        csText = "<script type=""text/javascript"" src=""" + getControlPath(Control.TemplateSourceDirectory) + "/greybox/gb_scripts.js""></script>"
        If (Not cs.IsClientScriptBlockRegistered(cstype, csname)) Then
            Page.ClientScript.RegisterClientScriptBlock(cstype, csname, csText.ToString, False)
        End If

 

 
New Post
8/13/2009 3:37 PM
 

 I think ResolveURL is what you are looking for.

<script src="<%=ResolveUrl("js/module.js")%>" type="text/javascript"></script>
In this example, my module.js is located in a js subfolder. The clientside output looks like
         <script src="/DnnSourceMultiforms/DesktopModules/TestingUnitTests/js/module.js" type="text/javascript"></script>
Which works the best since my project is not in the root of the site, it's in the folder 'DnnSourceMultiforms'. Most other methods I toyed with before finding ResolveUrl had trouble with not being in the root of the site.

 

 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Module Absolute PathModule Absolute Path


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