Click here to Skip to main content
11,647,600 members (63,875 online)
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 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
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 jyo.net 500
1 F-ES Sitecore 370
2 DamithSL 335
3 OriginalGriff 322
4 CPallini 290
0 OriginalGriff 1,342
1 jyo.net 994
2 DamithSL 971
3 Sergey Alexandrovich Kryukov 873
4 CPallini 795


Advertise | Privacy | Mobile
Web03 | 2.8.150804.2 | Last Updated 28 Mar 2012
Copyright © CodeProject, 1999-2015
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