Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0
Hi All,
 
Hi,
I want to call javascript function from aspx.cs. In Button click I will check for some conditions, corresponding to that conditions I have to call javascript function. Is it possible
Posted 22-Dec-10 0:51am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

hi,
use this code in your method..
Page.RegisterStartupScript("OnLoad","<script>functionName();</script>");
Hope This may help you..
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Rajesh Puli at 22-Dec-10 7:16am
   
Good One
Kasson at 22-Dec-10 5:56am
   
Good Call My 5.
Dalek Dave at 22-Dec-10 6:37am
   
Good Links.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

if (!ClientScript.IsStartupScriptRegistered("alert"))
   {
       Page.ClientScript.RegisterStartupScript(this.GetType(),
           "alert", "alertMe();", true);
   }
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

It is very easy to call javascript function from code behind asp.net .
 
In .cs code write
 

 string url = "yourpage.aspx?ManiFestNumber=" + value;
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "rates", "openWindow('" + url + "');", true);      


 

in aspx page just write in this code
 

 

<script type="text/javascript">
 
    function openWindow(url)
{
    var w = window.open(url, '', 'width=1,height=1,toolbar=0,status=0,location=0,menubar=0,directories=0,
resizable=0,scrollbars=0');
    w.focus();
}
 

 

 
and Its done .........
http://thedotnetdeveloper.blogspot.in/2012/03/call-javascript-function-from-code.html[^]
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 5,170
1 DamithSL 4,357
2 Maciej Los 3,750
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,851


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 28 Mar 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100