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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Need to Share Client-Side Variables Between ModulesNeed to Share Client-Side Variables Between Modules
Previous
 
Next
New Post
3/12/2008 4:40 PM
 

Can someone show me a way to create a client-side variable in one module for another module on the same page to use?  I have tried playing with the ClientAPI (shown below), but so far it hasn't worked for me. The variable would be a simple string value. 

Here is what I tried during testing (following the example in the documentation):

IN CODE-BEHIND:

' In the page_load event
DotNetNuke.UI.Utilities.ClientAPI.RegisterClientVariable(Me.Page, "TestVar", "Sucess!!", True)

IN MARK-UP:

// at the bottom of the module mark-up
var oVar = dnn.getVar('TestVar');

[EDIT]

After that, I decided to try the other example of setting and retrieving the value on client-side, and when that line of JavaScript attempts to execute, the browser crashes.  Here is what I put in the mark-up just below the other JavaScript snippet from above:

dnn.setVar('newTest','SUCCESS!!!');
var oVar2 = dnngetVar('newTest');

[/EDIT]


Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
New Post
3/13/2008 9:23 AM
 

I don't know if this will work, but have you tried using a session variable

hope it works

Mike

 
New Post
3/13/2008 1:56 PM
 

You can always try setting a JavaScript variable to the value you want to be used in the other module..

In the code-behind of one module:
Response.Write("<script language=JavaScript>")
Response.Write("var prefix = dnn_ctr" & Module.Id.toString() & "_yourModuleName_ctl00_")
Response.Write("var myVariable = '" & strVariable & "';")
Response.Write("</script>")

On the client side of your other module, you can retrieve it like this:
<script language=JavaScript>
document.getElementById(prefix + 'txtHiddenField').value = strVariable;
</script>

<input id="txtHiddenField" name="txtPositionHold" type="hidden"  runat="server" />

Then you can access that value in the code behind of your second module if you reference txtHiddenField.  You might have to stick this at the top of your code behind:
Imports System.Web.UI.HtmlControls.HtmlInputHidden

 
New Post
3/13/2008 3:15 PM
 

Thanks for the suggestions.  Due to the complexity and amount of code (not to mention business logic), I cannot post my fix, but I went with a combination of DotNetNuke.UI.Utilities.ClientAPI.RegisterStartUpScript and DotNetNuke.UI.Utilities.ClientAPI.RegisterClientScriptBlock to accomplish this.

The combination was necessary to ensure that variable scope was correct for both of the modules since one would be rendered prior to the other.


Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Need to Share Client-Side Variables Between ModulesNeed to Share Client-Side Variables Between Modules


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