Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
call javascript function from code behind on condition
Posted
Comments
Stephen Hewison 27-Sep-12 6:18am    
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

XML
<script type="text/javascript">
    function Showalert(text1,text2) {
        alert(text1 + text2);
    }
</script>



Code Behind will be

C#
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
 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900