Liam
Liam

Reputation: 9855

jQuery issue with .net

I'm working on a website built with .net and im having a strange problem.

I have a jQuery call that changes all my 'select' tags from the default browser style to a custom style. When my page loads the javascripit is read and so this works, my only problem being that when you select an option the dropdown, when the page reloads it seems to lose the styling and reset back to the browser style, as though the page is reloading without the jQuery.

Does this make sense? if so is there anyway to combat this?

Thanks

Upvotes: 0

Views: 77

Answers (1)

Robb
Robb

Reputation: 3851

It sounds like you're getting a partial post back.
As the page doesn't fully reload it doesn't fire your jquery pageload events but it is overwriting your links.

There are two possible ways to combat this,

First, stop the dropdown posting back by setting AutoPostBack="false" in its declaration in the aspx page. Obviously if you need the postback to happen this will break other things.

Secondly you could tie into the .net ajax methods

in your <head></head> add

<script type="text/javascript">
        function pageLoad() {
            //Code goes here
        };
    </script>

pageLoad fires on partial postback too so should work every time.

Upvotes: 2

Related Questions