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 ForumsClientAPIClientAPImaking a javascript alert pop up when clicking a buttonmaking a javascript alert pop up when clicking a button
Previous
 
Next
New Post
5/5/2006 7:31 AM
 
Hi,
I'm trying to get the client api to respond but somehow I cant even get a javascript to fire when clicking a button.
  The folloing works fine (in c#) :
myButton.Attributes.Add("onclick", "alert('This JS function was added on the fly!');");

However, if I create a file called "test.js" with a function looking like this:

function test()
{
    alert('test');
}

and I then want the function to execute when clicking the button, nothing happens...

myButton.Attributes.Add("onclick", "test");

Can anyone tell me whats wrong with my syntax or what I need to do?
I'm using visual web developer and I've placed the test.js file in the same directory as myModule, also I've tried to register the file using the following code:

if (this.Page.ClientScript.IsClientScriptBlockRegistered("test.js") == false)
                {
                    this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
                        "test.js", "<script language=javascript src=\"" + this.ModulePath +
                        "test.js\"></script>");
                }

Thanks,
Johannes 
              
 
New Post
5/8/2006 10:33 AM
 

Looks like you are missing the parenthesis in your onclick handler. 

myButton.Attributes.Add("onclick", "test");

should be

myButton.Attributes.Add("onclick", "test()");


 
New Post
5/10/2006 5:11 AM
 
thanks, silly error...
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPImaking a javascript alert pop up when clicking a buttonmaking a javascript alert pop up when clicking a button


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