1

I've just started to use jquery and asp.net, bearing this in mind I was wondering if someone could help me with the following question.

say I have an ASP:Link which when clicked performs a server side function "setData()", I then have jquery to set the class of the link to selected or hide the link (using animation). the problem im having is that when you press the link the server goes and does what it has to and reloads the page, this in turn reloads the whole DOM and the stuff jquery does is deleted.

is there any way i can have both the jquery and asp.net working together without the asp.net reloading the page. I hope this makes sense. I know I can set the links cssclass to be selected from the server side but the above example is just a simple example.

2
  • Could you show some code so I can have a better idea of what you're talking about? Unless your question is answered, then nvm :) Commented Feb 14, 2012 at 19:16
  • Please don't add "c#" and such to your titles. That's what the tags are for. Commented Feb 14, 2012 at 19:59

2 Answers 2

1

There are definitely a few ways you can go about this... But, going off your description, I would say that the easiest route would be to use an update panel (System.Web.UI.UpdatePanel), doing a partial page postback. From there you can control the visibility of the link, panel, etc... Otherwise, look into doing partial page postback using jQuery itself (using jquery.get or jquery.post).

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

1 Comment

+1, this is definitely the easiest way to get started. But you also need to be aware that $(document).ready doesn't fire after a partial page update. You might need pageLoad / Sys.Application.add_load to add jquery functionality to elements added by a partial page load: encosia.com/document-ready-and-pageload-are-not-the-same
0

Anytime you issue a postback this is going to be an issue, you would need to do an ajax call to your server side method in order for things to work the way you would like. I suppose there might be a workaround in order to have postback and your jquery click, but it would be sloppy. Ajax call would be the best solution.

This article should be of a lot of help to get going on this. http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/

Comments

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.