Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,
I want to call client side java script function from server button click event.
I am tried but its not working. In my project I set update panel in master page when I remove update panel from master page it work fine but when I set update panel then code not working.
here is the code

<script type="text/javascript" >
function abc(obj) {

        BootstrapDialog.confirm(obj, function (result) {
            if (result) {
             
            } else { return false; }
        });
    }             
</script>


protected void Button1_Click(object sender, EventArgs e)
        {
               this.Page.ClientScript.RegisterStartupScript(this.GetType(), "Warning","abc('test')",true);
        }


Please sugggest me how to implement it using update panel.
thank you
Posted

1 solution

Try this..

C#
// if you are using Ajax update panel use ScriptManager.RegisterClientScriptBlock
          ScriptManager.RegisterClientScriptBlock(this,this.GetType(), "Warning", "abc('test')", true);

           // if not Ajax Update panel
          this.Page.ClientScript.RegisterStartupScript(this.GetType(), "Warning", "abc('test')", true);
 
Share this answer
 
v2
Comments
GANESHGITE 29-Jan-14 5:16am    
thank you its working.. :)
Karthik_Mahalingam 29-Jan-14 5:19am    
Welcome Ganesh:)
Joezer BH 29-Jan-14 11:43am    
5ed!
Karthik_Mahalingam 29-Jan-14 13:07pm    
Thanks Canny Brisk :)

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