side updatepanel |
|
|
|
|
Recently I faced a weird issue while using Richtext or InputFormTextBox control of SharePoint. Actually there were many fields in the custom form, so to avoid postback I decided to use UpdatePanel for partial page update. Unfortunately my richtext contol was inside UpdatePanel and started showing weird behavior after asynchronous postback.
Before postback richtext control
After postback richtext control
Actually SharePoint calls few JavaScript methods to maintain the toolbar and look of richtext control on page load. But while partial page update browser don't trigger window onload event. That is why, JavaScript methods associated with richtext control don't get triggered and control looks completely different after asynchronous postback.
It means, somehow we have to call these method after asynchronous postback complete. To solve this problem you can use client side endRequest event of asynchronous postback to call required javaScript methods richtext control.
Sample Code:
<script type="text/javascript"> Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); function EndRequestHandler() { var richtextContolId = '<%= richtextControlId.ClientID %>'; if (browseris.ie5up && browseris.win32 && !IsAccessibilityFeatureEnabled()){ g_aToolBarButtons = null; g_fRTEFirstTimeGenerateCalled=true; RTE_ConvertTextAreaToRichEdit(richtextContolId, true, true, "", "1033",null, null, null, null, null,"FullHtml", " RTE_TextAreaWindow_OnLoad(richtextContolId); } else{ document.write(" }; } script> |
That's all you need to do to fix the above issue. After each asynchronous postback "EndRequestHandler" method will get called and it will maintain the state of richtext control. Go through the following blog to get good idea about client side events:http://www.a2zmenu.com/Blogs/Ajax/Call-JavaScript-method-after-Ajax-call-complete.aspx .
Problem with sharepoint inputformtextbox control with updatepanel
Click for help about adding basic HTML formatting.
");