0
<script type="text/javascript">

$(document).ready(function(){

    $(".btn-slide").click(function(){
        $("#panel").slideToggle("fast");
        $(this).toggleClass("active"); return false;
    });


});

</script>

How can i call this function when an asp.net button is clicked?

Also How can I make

<a href="#" id = slidebutton class="btn-slide" style="color: black" shape="circle">DASHBOARD</a>

run a asp.net button when it is clicked, or update an updatepanel

3
  • Consider $(function() { }); instead of $(document).ready(function() { }); Commented Jan 19, 2011 at 14:49
  • where would i put the fucntion name Commented Jan 19, 2011 at 14:52
  • Is this a question for me? What function name? Commented Jan 19, 2011 at 15:02

1 Answer 1

2

Make what you want to do a normal javascript function instead. If you return false it won't post back, if you return true it will. Just keep in mind that if you put this in an update panel and you post back your toggleclass is going to get blown away probably (assuming that the button is inside the update panel and it gets re-rendered).

function btnClick() {
    $("#panel").slideToggle("fast");
    $(this).toggleClass("active"); return false;
}

Sign up to request clarification or add additional context in comments.

5 Comments

thanks this worked, how could i do this vice versa where btn-slide runs an asp.net functions
You can have both an onClientClick and an OnClick event on the same button control. So just add a normal OnClick event and you should be set.
i still dont get it : / i know what onclientclick and onclick are but would it jut be <a href="#" id = slidebutton class="btn-slide" style="color: black" shape="circle" OnClick="myvbfunction()">DASHBOARD</a>
@MyHeadHurts In case you didn't notice, it should be id="slidebutton" or id=slidebutton. Remove the spaces.
@MyHeadHurts - To have the vbfunction work your control has to be a server control, meaning it has a runat="server" in it. For your purposes I would probably use a LinkButton control since it looks like a link instead of a button, which is what it sounds like you want to accomplish.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.