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

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIUsing the ClientAPI ...Using the ClientAPI ...
Previous
 
Next
New Post
11/10/2006 3:11 PM
 
After giving up on using the ClientAPI, I've recently tried to use it again, and again with no avail! ... I'm not really sure what I am doing wrong, but if someone could point me in the right direction, or better yet, just tell me what I am doing wrong that would be great ...

Here is what I am trying to do with the code:

Registering a .js script with DNN, Registering a ClientVariable ...

 If Me.Page.IsClientScriptBlockRegistered("countdown.js") = False Then
     Me.Page.RegisterClientScriptBlock("countdown.js", "<script language=javascript src=""" & Me.ModulePath & "countdown.js""></script>")
     ClientAPI.RegisterClientVariable(Me.Page, "ctrID", Me.ClientID, True)
     ClientAPI.RegisterClientVariable(Me.Page, "TargetDate", Me.ClientID, True)
 End If

Here is the .js file (It displays a count down on the web page)...

ctrID = "";
TargetDate = "";
BackColor = "";
ForeColor = "";
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = " %%H%%:%%M%%:%%S%%.";
FinishMessage = " Out of time!";

function calcage(secs, num1, num2) {
  s = ((Math.floor(secs/num1))%num2).toString();
  if (LeadingZero && s.length < 2)
    s = "0" + s;
  return "<b>" + s + "</b>";
}

function CountBack(secs) {
  if (secs < 0) {
    alert("Time has run out!");
    window.location.href = '/DotNetNukeSource/';
  }
 
  DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
  DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
  DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
  DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));

  document.getElementById("cntdwn").innerHTML = DisplayStr;
  if (CountActive)
    setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
}

//******************************************
//Rather than using the document.write, I'd much rather just use the .innerHTML of a control on the web page, but I can't seem to register that control correctly either, so for now I am using the following a just drawing a <span> tag.
function putspan(backcolor, forecolor) {
 document.write("<span id='cntdwn' style='background-color:" + backcolor +
                "; color:" + forecolor + "'></span>");
}

if (typeof(BackColor)=="undefined")
  BackColor = "white";
if (typeof(ForeColor)=="undefined")
  ForeColor= "black";
if (typeof(TargetDate)=="undefined")
  TargetDate = "12/31/2020 5:00 AM";
if (typeof(DisplayFormat)=="undefined")
  DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
if (typeof(CountActive)=="undefined")
  CountActive = true;
if (typeof(FinishMessage)=="undefined")
  FinishMessage = "";
if (typeof(CountStepper)!="number")
  CountStepper = -1;
if (typeof(LeadingZero)=="undefined")
  LeadingZero = true;


CountStepper = Math.ceil(CountStepper);
if (CountStepper == 0)
  CountActive = false;
var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
putspan(BackColor, ForeColor);
var dthen = new Date(TargetDate);
var dnow = new Date();
if(CountStepper>0)
  ddiff = new Date(dnow-dthen);
else
  ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountBack(gsecs);

Basically because I can't seem to get my .js to play nicely with the ClientAPI here is the route I've taken for now until someone can explain to me what I am doing wrong or I just find another way ...

Dim scriptText As String

scriptText = "<script language=javascript>"
scriptText += "TargetDate = '11/10/2006 1:55 PM';"
scriptText += "</script>"
scriptText += "<script language=javascript src=""" & Me.ModulePath & "countdown.js""></script>"
Me.lblTime.Text = scriptText

As the later works fine, I'd really like to learn how to use the ClientAPI, properly ...

Thanks,
HBenton

Wisconsins DNN User Group: www.WIDNN.com
Visit my home page: www.HerbBenton.com
 
New Post
11/10/2006 4:09 PM
 

The only reference to the clientAPI that I see in the code is on the server side (ClientAPI.RegisterClientVariable).  On the client I see no dnn.getVar.   Please refer to the ClientAPI document for more information.

 


 
New Post
11/12/2006 7:45 PM
 
Jon Henning wrote

The only reference to the clientAPI that I see in the code is on the server side (ClientAPI.RegisterClientVariable).  On the client I see no dnn.getVar. 

I had the dnn.getVar added in there and then I took it out after not being able to get the clientAPI to play nicely with my code ... I posted this thread after getting my code to work in the later example of my thread ...

Jon Henning wrote

Please refer to the ClientAPI document for more information.

I've looked at the ClientAPI document, numerous times and numerous times I've been frustrated looking at it, I was really hoping to get someone to create some short piece of code that says something along the lines of "Put this here like this 'dnn.getVar(324234);' and then do this, blah, blah, blah ... so on and so forth" rather than pointing to the documentation on the API

To this point the only area of DotNetNuke that frustrates me is the ClientAPI and I have been downloading and implementing DotNetNuke within our intranet at work since v1.0. Maybe a re-write on the documentation is in order.


Wisconsins DNN User Group: www.WIDNN.com
Visit my home page: www.HerbBenton.com
 
New Post
11/13/2006 9:56 AM
 

I've looked at the ClientAPI document, numerous times and numerous times I've been frustrated looking at it, I was really hoping to get someone to create some short piece of code that says something along the lines of "Put this here like this 'dnn.getVar(324234);' and then do this, blah, blah, blah ... so on and so forth"

Did you read Page 6 of the document? 

An example of where this functionality is used is in the maximize/minimize client script.  Since in an UpLevel rendering of a module with the maximize/minimize functionality a round trip to the server is not done and the icon representing the plus and minus sign can be customized, the client will need to know what icons to display when clicked.  This information is set on the server side and passed to the client by the following code.

 

ClientAPI.RegisterClientVariable(Page, "min_icon_" & objPortalModule.ModuleId.ToString, sModulePath & [MinIcon], True)

 

Then it is accessed on the client side by the following code.

 

sMinIcon = dnn.getVar('min_icon_' + sModuleID);

Is this not what you are asking for? 

rather than pointing to the documentation on the API

What is the documentation for then if not to show you how to use it?  The document states this is how you use it, and here is a sample of where in the core it is used.

I had the dnn.getVar added in there and then I took it out after not being able to get the clientAPI to play nicely with my code

You take it out, and ask why its not working???  How are you supposed to get help, if you don't post the part of the code that you are having trouble with? 


 
New Post
11/21/2006 11:19 AM
 

Jon –

I just wanted to apologize for blasting you in the forum about the documentation. As you can see some time has gone by since my last post, in this time I have been trying to work with the ClientAPI to implement it into a project that I have been working on here at work … I think a combination of the lack of requirements supplied to me on this project at work and my lack of knowledge of the ClientAPI just triggered my frustrations and, well, as a result I fired off on you … my sincere apologizes!

HBenton


Wisconsins DNN User Group: www.WIDNN.com
Visit my home page: www.HerbBenton.com
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIUsing the ClientAPI ...Using the ClientAPI ...


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