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 ForumsClientAPIClientAPIHelloAJAX sample problemsHelloAJAX sample problems
Previous
 
Next
New Post
8/28/2006 11:15 PM
 
Hi Jon

I've implemented the HelloAJAX into a module, but I'm having difficulties seeing how it works ...

I get an error:

"400 - unable to cast object of type System.Web.UI.HtmlControls.HtmlTitle' to type 'DotNetNuke.UI.Utilities.IClientAPICallbackEventHandler"

My ASCX control with HelloAJAX is loaded into a placeholder in another ASCX that is loaded by another ASCX that is loaded by a module(! yes I know thats not great), so I guess that it is having problems finding the correct parent control...

The code I used (HelloAJAX converted to C#) is:

public class Foo : Bar, IClientAPICallbackEventHandler  // class Bar inherits from PortalModuleBase

protected TextBox txtAjax;
protected Button btnAjax;
protected CheckBox chkAjax;
protected Label lblAjax;

private void Page_Load(object sender, System.EventArgs e)
{
           this.btnAjax.Attributes.Add("onclick", ClientAPI.GetCallbackEventReference(this, "dnn.dom.getById('" + this.txtAjax.ClientID + "').value", "successFunc", "'" + this.ClientID + "'", "errorFunc"));
            this.chkAjax.Attributes.Add("onclick", "toggleCont('" + this.ClientID + "')");

            if (!this.Page.ClientScript.IsClientScriptBlockRegistered("helloajax.js"))
            {
                this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "helloajax.js", "<script language=javascript src='" + this.ModulePath + "helloajax.js'></script>");
            }
  // ... etc
}

public string RaiseClientAPICallbackEvent(string eventArgument)
{
            return "Hello AJAX!" + "\r\n" + eventArgument + "\r\n" + DateTime.Now.ToString();
}

Does the parent module have to implement IClientAPICallbackEventHandler as well or is it sufficient to have the ASCX implement it?

In the case of an ASCX that is embedded several layers deep, does each of it's parent ASCX controls also have to implement IClientAPICallbackEventHandler?

In HelloAJAX, Blue.ascx.vb the comment reads "'two levels up, since immediate parent is the placeholder" -- what exactly is the required control to use in ClientAPI.GetCallbackEventReference()?  The module's top level control, or the ... ? (in my case I have a placeholder in a placeholder in a placeholder, all of which use LoadControl)

I think ClientAPI looks good and will really make these modules great :) .. once I figure out how to use it! :)

Thanks!

JK


You know your website is cool, so why not let your users help you by spreading the word on social networking sites - get the DotNetNuke Social Bookmarks Module with 57 different ways to add social bookmarks to your site ... or download the FREE demo right now
 
New Post
8/29/2006 12:22 AM
 
Made some progress :)

... by using the example from HelloAJAXContainer, I have my top ascx passing the RaiseClientAPICallbackEvent call down to it's child ascx, which passes the call to its child ascx, which has the actuall callback function

I had to use ClientAPI.GetCallbackEventReference(this.Parent.Parent.Parent.Parent, ...) in order to get the correct start control (ugly) - is there anything I can do about this?

Unfortunately immediately after the callback function, there is a pageload, so the helloajax label gets wiped out - I will have to keep looking further into it

JK.

You know your website is cool, so why not let your users help you by spreading the word on social networking sites - get the DotNetNuke Social Bookmarks Module with 57 different ways to add social bookmarks to your site ... or download the FREE demo right now
 
New Post
8/29/2006 9:48 AM
 

To understand the sample better, please refer to this blog

The first question is, are you dynamically loading modules.  If not, then the code in that blog, and therefore sample is not really what you are after.  In other words, if the control that you are needing is already present for the page's init event, you should just be able to reference it directly.   You are using this.parent.parent.parent.parent...   why not just reference it by its actual name?  Again, if you are dynamically loading the contols, you cannot directly reference.  Instead you need to reference a control to handle the request that is present during init.

I also want to note that a new enhancement that I am in the process of making as part of the DNNTabStrip should completely simplify a lot of this.


 
New Post
8/31/2006 10:38 PM
 
Jon Henning wrote

To understand the sample better, please refer to this blog

The first question is, are you dynamically loading modules.  If not, then the code in that blog, and therefore sample is not really what you are after.  In other words, if the control that you are needing is already present for the page's init event, you should just be able to reference it directly.   You are using this.parent.parent.parent.parent...   why not just reference it by its actual name?  Again, if you are dynamically loading the contols, you cannot directly reference.  Instead you need to reference a control to handle the request that is present during init.

I also want to note that a new enhancement that I am in the process of making as part of the DNNTabStrip should completely simplify a lot of this.



Hi Jon,  thanks I hadnt read that blog post

I'm dynamically loading user controls, not modules ..  I did get it to work by using the same method as shown in helloajax blue/red, but with a few extra levels of depth added :)

Each parent ascx handles the RaiseClientAPICallbackEvent by creating its child control and calling childcontrol.RaiseClientAPICallbackEvent .. and since that child control is also a parent it also creates its child and calls child.RaiseClientAPICallbackEvent, until finally the lowest level child control is loaded and it does the actual handling of the call back.

This has worked great, although I still have to use parent.parent.parent.parent which is ugly, I cant reference the first control in the parent chain by name, because the lowest level child doesnt know who its top level parent is

JK.

You know your website is cool, so why not let your users help you by spreading the word on social networking sites - get the DotNetNuke Social Bookmarks Module with 57 different ways to add social bookmarks to your site ... or download the FREE demo right now
 
New Post
9/1/2006 9:16 AM
 
That makes sense.  Would you mind sending me a simple installable example of your use-case?  I want to verify that my new enhancement to the ClientAPI callbacks will be benificial to it. 

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIHelloAJAX sample problemsHelloAJAX sample problems


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