0
<script type="text/javascript" language="javascript">
    function pageLoad(sender, args) {
        $('#bvft').addClass("bvft");

        $('#new').live('click', function() {
            $('#bvft').removeClass("bvft");
            $('#bvft').show("slow");
        });

        $('.ddlFrTime').change(function() {
            var vFTime = $('.ddlFrTime').val();

            if (vFTime != "") {
                $('#bvft').removeClass("bvft");
                $('#bvft').show("slow");
            }
            else { alert("sorry"); }
        }); 
    }        
</script>

In $('#bvft'), I have one dropdownlist

<asp:DropDownList ID="ddlFrTime" runat="server" Width="250px" CssClass="ddlFrTime" AutoPostBack="true"
                                    OnSelectedIndexChanged="ddlFrTime_SelectedIndexChanged">
                                </asp:DropDownList>

$(#bvft) is div id. $('#new') is button id. When page load, I want to disable. It works perfect. When I click the button, $(#bvft) div will show. But the problem is (in div, I have dropdownlist) when I select dropdownlist, the postback will work. At this time div is automatically hide back. How to prevent for this. Actually I used function pageLoad() to prevent postback. But it's not working.

4
  • does return false work? I know it stops the href action of a link. Worth a try I guess Commented May 11, 2011 at 2:59
  • do u mean 'return false' for button? if you mean like this... button is okay no problem... the problem is dropdownlist postback. thanks for reply... Commented May 11, 2011 at 3:02
  • Sorry, inside the jQuery event for change() Commented May 11, 2011 at 3:03
  • @PostMan I changed like this '$('.ddlFrTime').change(function() { var vFTime = $('.ddlFrTime').val(); if (vFTime != "") { $('#bvft').css('display', 'block'); $('#bvft').show("slow"); } return false; }); ' But not okay :( Commented May 11, 2011 at 3:11

2 Answers 2

2

Set autopostback to false for the dropdownbox

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

3 Comments

if i set autopostback to false, how to do for dropdownlist selectedIndexChanged?
Your page has to post if you want to fire that event.
@CMMaung what behavior you want in your selectedIndexChanged event? Does it have to be done in server side? if not, maybe you can do it with js
-1

Now I got an answer... I put some code after function pageLoad()... like this

function pageLoad(sender, args) {
        if (!args.get_isPartialLoad()) {
            $('#bvft').slideUp('slow');
        }
        else {
            $('#bvft').slideDown('slow');
        }
    }

It will work pretty... no problem for postback...

1 Comment

@iamserious which part you are not clear? you need to use that one if (!args.get_isPartialLoad())

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.