Click here to Skip to main content
Sign Up to vote bad
good
See more: C#4.0
call javascript function from code behind on condition
Posted 27 Sep '12 - 0:06

Comments
Stephen Hewison - 27 Sep '12 - 6:18
Sorry, not a well formed question. Can you provide a bit more detail?

1 solution

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  
Comments
sachin hanchate - 27 Sep '12 - 6:33
I have tried earlier but didnt worked..
Ahmed Mandur - 27 Sep '12 - 6:34
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
Your Filters
Interested
Ignored
     
0 OriginalGriff 325
1 Abhinav S 168
2 Sergey Alexandrovich Kryukov 150
3 Ron Beyer 100
4 Zoltán Zörgő 85
0 Sergey Alexandrovich Kryukov 8,386
1 OriginalGriff 6,596
2 CPallini 3,533
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 27 Sep 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid