0

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

5
  • Are you using update panels and how are you registering the jquery on the page? Commented Oct 25, 2011 at 10:22
  • Have you tried with sessions. Commented Oct 25, 2011 at 10:24
  • No I've no knowledge of .net unfortunately im just unsure why it posts data back to the page but fails to load the JS Commented Oct 25, 2011 at 10:28
  • Try and view the source of your page after changing the drop down selection and ensure that the script that alters the style is injected into the page after the select elements. Also set a breakpoint in javascript (ensure the browser allows for javascript debugging) and ensure the code it firing on each postback? Commented Oct 25, 2011 at 10:40
  • If you show some code we can find what and where the problem is going on! Commented Oct 25, 2011 at 10:41

1 Answer 1

2

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.

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

1 Comment

Ahh thanks @Robb its keeping the style but for somereason now the .net filter doesnt seem to work.

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.