Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

$4.95 Windows Hosting at Webhost4life.com
  Ads  
Aspose - The .NET & Java component publisher
 


  Sponsors  

Meet Our Sponsors

OnyakTech
CrystalTech Web Hosting™
Webhost4life, specialists in DNN hosting
Mad Development is a full service interactive agency focusing on the merge of design, technology, e-commerce, and affiliate marketing by providing total website solutions.
SteadyRain
DataSprings - Great Ideas. Always Flowing.
 


DotNetNuke Forums
 
  Forum  DotNetNuke® Pro...  ClientAPI Compo...  making a javascript alert pop up when clicking a button
Previous Previous
 
Next Next
New Post 5/5/2006 5:31 AM
User is offline Johannes Dolberg
19 posts
10th Ranked


making a javascript alert pop up when clicking a button 
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 8:33 AM
User is offline Jon Henning
1622 posts
www.codeendeavors.com
5th Ranked










Re: making a javascript alert pop up when clicking a button 

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 3:11 AM
User is offline Johannes Dolberg
19 posts
10th Ranked


Re: making a javascript alert pop up when clicking a button 
thanks, silly error...
 
Previous Previous
 
Next Next
  Forum  DotNetNuke® Pro...  ClientAPI Compo...  making a javascript alert pop up when clicking a button
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


Live Visitor Tracking & Live Chat For DotNetNuke
Track your visitors in real time and add live chat for sales & support. Free Trial.
www.whoson.com
SINA101
WANT A SPECial sIte iN TAIWAN?
sina101.com
Web Development and Strategy Firm
The Risdall Interactive Agency s websites, strategies, branding, & promotion in digital space.
www.Risdall.net/

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP