.net updatepanel and applet

User eda6f877b4

09-06-2009 12:57:35

Hi,


I have started re-writing an application from java to .net.


Built in with .net is their interpretation of ajax, and one of the controls is the update panel.


I have a number of text fields and the marvin skectch applet inside an update panel, when this update panel is updated, the serverside logic works fine, but the marvin applet dissappears.


Have you had any experience in mixing this...


(Jchem version is 5.2)


Regards

Dann

ChemAxon 6e93227fcc

09-06-2009 13:33:59

Hi,


I assume you use the Microsoft AJAX toolkit because you mentioned you have updatepanels. For your first problem I can guess is because of the way you create the Marvin applet editor. If you use the aproch with script elements inside other standard HTML elements then you will have to change it (or go for another solution which I will describe below). The problem ocures because the AJAX call is made to the server and then the response is set as innerHTML for your updatepanel container. In this situation the script element you have for applet creation will not be executed.


The best solution would be if you can put the applet editor outside the update panel and with javascript set molecules strings from applet to one of your textboxes (even the textboxes that are inside your updatepanel).


However maybe your layout does not allow this situation and you really need to have the applet inside your update panel. In this situation you should go for a different applet creation approach. If you look in marvin.js you will notice that in InternetExplorer the applet is an <object> element, in other browser is <applet> element and so on. You now have 2 options:


1. Create the right applet element tag from server side (you can check on server side what browser the user is using. If is IE create <object> element with all parameters. If it other create <applet> and so on).


2. If you will check the Microsoft AJAX toolkit you will find that there are some client side (javascript) events for update panel updated completed. You can handle those events on client side to "inject" the applet in the right place...


For your second problem:


I'm not sure if I understood correctly what is the situation but anyway:


I assume you want to redraw the molecule in marvin applet after a normal postback. In this situation you have again at least 2 options:


1. If your molecule is already saved in viewstate (so probably in one of your input type hidden element) then you can put an event on client side (like <body onload=...) and set the molecule for applet from javascript using setMol method of msketch.


2. If you will create the applet from server side then you can also create the parameter with molecule. Don't forget to encode the molecule string :).


Calin Naghi

User eda6f877b4

09-06-2009 18:55:13

Hi Calin,


Thanks for your quick reply. I will have a look at your suggested solutions, and report back..


Dann