Click here to Skip to main content
12,248,339 members (46,195 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# C#4.0
call javascript function from code behind on condition
Posted 27-Sep-12 1:06am
Comments
Stephen Hewison 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 27-Sep-12 6:33am
   
I have tried earlier but didnt worked..
Ahmed Mandur 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 27 Sep 2012
Copyright © CodeProject, 1999-2016
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