Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi, i have this jqery function
<pre lang="Javascript"> <script type="text/javascript">

    $(document).ready(function Ocultar() {
        //Oculta-Aparece-Derecha
        $('#toggle-right').toggle(function Ocultar1() {
            //Derecha
            $('#right-sidebar').animate({
                width: "850px",
                backgroundColor: "#ffffff"
            }, 400);
            $('#button-right-sidebar').animate({ right: "850px" });

        }, function () {
            $('#right-sidebar').animate({
                width: "0px",
                backgroundColor: "#00000"
            }, 400);
            $('#button-right-sidebar').animate({ right: "0px" });            
        });

        $('#toggle_medidas').toggle(function () {
            //Derecha
            $('#medidas').animate({
                width: "90px",
                backgroundColor: "#ffffff"
            }, 400);
            //$('#botonMedidas').animate({ left: });

        }, function () {
            $('#medidas').animate({
                display: "none", width: "0px",
                backgroundColor: "#00000"
            }, 400);
            //$('#botonMedidas').animate({ left:  });
        });
    });

</script>


and i'm trying to call from code behid in a button event
i hope someone can help me

thanks
Posted
Comments
db7uk 7-Feb-13 14:44pm    
why not call the function from the client side? calling from server side makes no sense? what are you trying to do?
FelipeVazquez 7-Feb-13 14:59pm    
I have a div that opens and closes with this function, and a button that updates an updatepanel, I want the div is closed by pressing the button without the page is updated
I put this code on the button event
Page.ClientScript.RegisterStartupScript(Me.GetType(), "toggle", "Ocultar();", True)
but does not work
thanks for your help

pd: sorry for my english
bbirajdar 7-Feb-13 23:40pm    
Here is your confusion - Page.ClientScript.RegisterStartupScript(Me.GetType(), "toggle", "Ocultar();", True) ..Is used for registering the script on the page. However , the client side script - javascript has to be 'called/executed' from client side only...


1 solution

From your question, I have guessed that you are a novice in web technologies and web development..

You should remember that ..
1. HTTP is a stateless protocol. A server does not know who the client is. It only responds to the requests from the client. So it cannot call a client side function.


Rather you should call this function in the client side click event..
 
Share this answer
 
Comments
FelipeVazquez 7-Feb-13 15:10pm    
it's that obvious?
Thanks for your answer, helped me see it from another angle
bbirajdar 7-Feb-13 15:14pm    
Yes..The javascript is loaded on client side..So you can execute it on the client side itself....
db7uk 7-Feb-13 15:59pm    
Good answer
bbirajdar 7-Feb-13 23:37pm    
Thank you
Sergey Alexandrovich Kryukov 7-Feb-13 18:39pm    
It's a rare case OP could get it. Many perceive it as this is impossible because the advisor is bad. :-)
My 5.
—SA

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