Click here to Skip to main content
12,953,491 members (55,753 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
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 21-Dec-10 23:51pm
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
Kasson 22-Dec-10 5:56am
   
Good Call My 5.
Dalek Dave 22-Dec-10 6:37am
   
Good Links.
Rajesh Puli 22-Dec-10 7:16am
   
Good One
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
Top Experts
Last 24hrsThis month
OriginalGriff 6,429
CHill60 3,490
Maciej Los 3,103
ppolymorphe 2,020
Jochen Arndt 1,975


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 28 Mar 2012
Copyright © CodeProject, 1999-2017
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