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  |  

AppTheory specializes in solutions based on the DotNetNuke platform and has 2 employees on the DotNetNuke Core Team.
  Ads  
 


  Sponsors  

Meet Our Sponsors

SmarterTools
Verndale
The Official Microsoft ASP.NET Website
Portal Webhosting - Hosting For Developers
Red-Gate Software
MaximumASP
 


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.

 


SteadyRain
Founded in 1999, SteadyRain has extensive experience delivering Internet technology strategies and solutions for a diverse client base, ranging from Fortune 500 firms to successful start-ups.
www.steadyrain.com
AfterImage Internet Consulting and SEO Services
AfterImage provides search engine optimization (SEO), Internet consulting and hosting services for the Windows platform (IIS, ASP, SQL Server).
www.afterimage.nl/
Alki Homes - Seattle, WA
Exemplary service for your Seattle Real Estate needs. It's what you deserve from your Realtor®!
www.alkihomes.com

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