Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
string script = "<script language="\"javascript\"" type="\"text/javascript\"">";
            script += "function chartPopup2()";
            script += "{";
            script += "alert(‘test’);";
            script += "}";
            script += "</script>";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "test", script);---this line is not working

Above code written in btn click event in server side.

I clicked button but JavaScript is not working.
Please send me needful answer.
Posted
Updated 29-Jul-10 2:18am
v2
Comments
Sandeep Mewara 29-Jul-10 8:24am    
Reason for my vote of 1
Third time posted the same thing.

This is the THIRD [^]time you are asking the same thing.
Are you that dumb? A simple thing has been suggested to you.

How did you bind this script with your button?
Did you do:
C#
btnClick.Attributes.Add("onclick", "chartPopup2();");

You need to bind the JavaScript method to the button. System is not intelligent enough to apply your JavaScript method to a button by itself.

If you are unable to make out, go study some books, learn how to learn first.
 
Share this answer
 
v2
This code is looking horrible. You can also use OnClientClick of button for calling javascript. Why you want to do like this? Anyway in this code you are declaring a function, but not calling it. Remove that function and keep only that alert, then it'll work. Or simply you can do something like,
<br />
Page.ClientScript.RegisterStartupScript(this.GetType(), "test", "alert('test');", true);
 
Share this answer
 
v2
Comments
Sandeep Mewara 29-Jul-10 8:28am    
Well, this is third time we are trying to explain him that it is just declaration of a function and not calling... but :doh:
Arun Jacob 29-Jul-10 8:30am    
I didn't know that this question is a repost :-)
raju melveetilpurayil 29-Jul-10 9:01am    
anyway both of you did a good job.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900