سؤال

I was wondering if anyone could clear the confusion for me. I am trying to implement drag and drops of controls through j query.

  1. There is an init JavaScript function client side which makes all the controls of a certain class draggable and droppable.

  2. The controls are created dynamically code behind.

  3. The controls are recreated every post back even partial ones.

My problem was that these controls were losing there draggable and droppable property after post-backs, so to fix it, I started registering scripts code behind using RegisterStartupScript with a different key whenever an event was fired which would recreate the controls. Can any body shed some light to it and explain why do I need to register a script every time when a page loads. Is this normal or am I missing something.

Thanks.

هل كانت مفيدة؟

المحلول

When you do a partial postback that updates particular html elements, those elements are recreated and therefore lose their javascript event bindings. The startup script recreates those bindings.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top