Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
call javascript function from code behind on condition
Posted 27-Sep-12 0:06am
Comments
Stephen Hewison at 27-Sep-12 6:18am
   
Sorry, not a well formed question. Can you provide a bit more detail?

1 solution

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

Solution 1

Hi,
 
Let's say we have Javascript Function Called Showalert
 
<script type="text/javascript">
    function Showalert(text1,text2) {
        alert(text1 + text2);
    }
</script>
 

Code Behind will be
 
        if (Condition)
        {
            string Text2 = "Ahmed";
            string Text1 = "My Name Is : ";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "starScript", "Showalert('" + Text1 + "','" + Text2 + "');", true);
        }
 

Hope this help you
 
Regards,
Ahmed Mandour
  Permalink  
v2
Comments
sachin hanchate at 27-Sep-12 6:33am
   
I have tried earlier but didnt worked..
Ahmed Mandur at 27-Sep-12 6:34am
   
Please Post your code . it works for me

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 368
1 Richard MacCutchan 240
2 OriginalGriff 230
3 Jared Sanow 145
4 Vinay Mistry 133
0 Sergey Alexandrovich Kryukov 5,955
1 OriginalGriff 4,805
2 CPallini 2,473
3 Abhinav S 1,507
4 Richard MacCutchan 1,437


Advertise | Privacy | Mobile
Web01 | 2.8.140814.1 | Last Updated 27 Sep 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