Could i use page unload event in Class Library (Web part)?

Hi,
I am creating Web Part using visual studio class library. I am going to deploy it in SharePoint environment.
I want to do some functionality while page unload. Is there anything like that?
Could anyone tell about it?
Thanks & Regards
Poomani Sankaran

Hi,
According to your description, my understanding is that you want to create a web part programmatically and then do some functionality in the page unload event.
There is a web part method called WebPart.OnUnload method, you can override this method and add the custom code to the override method.
Here are some detailed articles for your reference:
https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.webpart.onunload(v=office.14).aspx
http://www.codeproject.com/Articles/25019/Developing-SharePoint-WebParts
Thanks
Best Regards
Jerry Guo
TechNet Community Support

Similar Messages

  • Is it possible to trigger action in backing bean on page unload event?

    Hi,
    There is a RichPopup in my page which has a Listener to save data or not by user choice "Data change detected, do you want to save those changes?"
    I've tried with the javascript event 'window.onbeforeunload', but this way must be fit with a Servlet function which I am not allowed to use.
    The attibute 'onunload' in the tag '<af:document>' seems useless. Even there is few description or example in the 'Tag Reference'.
    So, is it possible to trigger action in backing bean on page unload event? Thanks in advance for helping.
    Viva

    Hi Frank
    Thanks for helping, I've tried in your way. My codes are like below:
    Page codes:
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <jsp:directive.page contentType="text/html;charset=UTF-8"/>
      <f:view>
        <af:document id="d1" clientComponent="true" title="viva test">
          <af:resource type="javascript">
            if (!window.addEventListener) {
                // alert('window.addEventListener is not supported in IE8. Override it!');
                window.addEventListener = function (type, listener, useCapture) {
                    window.attachEvent('on' + type, function() {listener(event)});
            window.addEventListener('beforeunload', function (){performUnloadEvent()}, false);
            function performUnloadEvent() {
              var eventSource = AdfPage.PAGE.findComponentByAbsoluteId('d1');
              //var x and y are dummy variables obviously neeed to keep the page
              //alive for as long it takes to send the custom event to the server
              var x = AdfCustomEvent.queue(eventSource, 'handleOnUnload', {args:'noargs'}, false);
              var y = 0;
          </af:resource>
          <af:serverListener type="handleOnUnload" method="#{vivaTestBean.testOnUnload}"/>
          <!--
          <af:form id="f1">
            <af:commandButton text="Unload" id="cb1" action="unload"/>
          </af:form>
          -->
        </af:document>
      </f:view>
    </jsp:root>The backing bean codes:
    public class VivaTestBean {
        public VivaTestBean() {
        public void testOnUnload(ClientEvent clientEvent) {
            System.out.println("Thanks God");
    }The first way which triggers a 'unload' event by clicking a button DO WORKS. :)
    But when I changed the triggered way by changing the <af:document> to clientComponent as what you did, the 'onbeforeunload' event won't come out when I refreshed or closed the page.
    That doesn't make sence, since I think the two ways to trigger a 'unload' event are the same.
    Edited by: 841766 on 2011-3-7 上午1:13

  • Using "View Selector" in the List View Web Part, changes the web part page to the view selected's page.

    Hi,
    I am relatively new to Web Parts pages.  I created a page with list view web part and a Infopath Form Web Part, which are connect via the "Get Form From" option.  My users would like to be able to use views dependent on what
    they are looking for.  So I created different views.  However, when I select the view from within the Web Part, it changes the web part page to the list view page.  I must be doing something wrong.  How do I configure the list view to show
    the selected view and results within the existing "list view web part"?
    Thanks,
    Dwayne

    Hi
    Lindali,
    Sorry, but this has not been answered to my liking.  The "List View Web Part" has the ability for the user to select the view from within the web part, so there you should be able to select a different view and have it appear within the same web part. 
    Does anyone know how to complete this task?
    Thanks,
    Dwayen

  • How To Expand And Display Recurring Events In Content Search Web Part?

    I have a requirement to display all upcoming events. So I used content search webpart to display all the events, however the only problem is that I'm unable to expand recurring events all together. Is there a way to do this?
    Vamsi Munagala

    Hi Vamsi,
    Per my knowledge, where is no OOB method to achieve your requirement.
    As a workaround, we can customize a web part to achieve it, querying Recurring Events using CAML Query and display the results in a SPGridView.
    https://jtheblog.wordpress.com/2011/08/10/sharepoint-caml-for-calendar-recurring-events/
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Sharepoint 2013 - Can I use Visual Studio 2012 express edition for web-parts and app parts?

    I am new to sharepoint 2013. I want to develop the app and web parts using visual studio 2012 express edition. Can I use vs 2012 express edtion to create app and web parts for sharepoint 2013?

    Unfortunately no, check this post:
    http://sharepoint.stackexchange.com/questions/52338/sharepoint2013-development-with-vs2012-express
    To build SharePoint 2013 webparts/apps you will need the 'Microsoft Office Developer Tools for Visual Studio 2012', which do not come as part of Visual Studio.  The tools require Visual Studio 2012 Ultimate, Premium, or Professional.
    The tools and prerequisites can be found here:
    http://msdn.microsoft.com/en-us/office/apps/fp123627.aspx
    Brandon Atkinson
    Blog: http://brandonatkinson.blogspot.com

  • Using page life cycle (OnPageLoadBackingBeanB)class to update page controls

    I used the onPageLoadbackingBeanbase class that exists in SRDemo to handle the page life cycle for my project ADF faces pages but found that the controls is null in all phases of the page
    How can i use the page life cycle for dealing with the page controls like
    filling selectOneChoice in the isPostback once not in every action or refresh
    thanks

    I sent this post 1 week ago and no response
    please help
    Message was edited by:
    user560167

  • Leaving a Page fires "Page Unload" dynamic action?

    Hi,
    Which Dynamic Action fires when I am leaving a page.
    I have a page with lot of items, I want to fire alert based on some condition when user leaving that page (suppose user clicks to say some TAB), I used *"Page Unload"* dynamic action, but somehow it's not working.
    Is there any other Event I have to use?
    Thanks,
    Deepak

    Thanks.. VC
    but I cannot use that plugin as I have a Page which call other pages using iFrame and I am facing some issue..
    I have created a separate Post for this but not able to resolve it till now.. Here is the Link.
    Re: "IFrame Region" Plugin / Save Before Exit (3.0.2) - Dialog box - Question
    Thanks,
    Deepak

  • How to enable a custom web part class file to be refreshed at regular interval of time, without affecting the entire page where its placed.

    Hi,
    I am calling a web service in the web part class file where it gets the data. I need to call the service at regular intervals of time which is in the web part, is there a way to get the web part refreshed automatically at certain intervals of time.
    Rayudu

    You can use Ajax for automatic refreshing.
    Add a timer control into an Ajax Update panel within your custom web part and execute your code to refresh the field values within the Timer_Tick() event.
    You can also control the timer interval to 10 minutes or so using the Timer.Interval property.
    This will always enable your page to remain with only the web parts getting refreshed.
    I just found
    a blog post which describes this in detail with screenshots.

  • ADF page unload

    Is it possible in to trigger action in backing bean on page unload event?

    Hi,
    this is a bit tricky in JSF because it uses postback by default to navigate from one page to the other. This means that it would first unload to reload and then fire the navigation event, after which its unloads again. I think - depending on your usecase - you need to find another hookpoint e.g. in the JSF lifecycle using a PhaseListener
    Frank

  • Dynamic Action on page unload

    Hi folks
    On one page of my app, I would like to save several page items to session state if the user clicks a tab to load another page. I am doing this so that if the user later returns to the first page, their work in progress can be restored from session state.
    As there are many items on the page and our internet connection is slow, I don't want to save each page item after it is changed or loses focus. I thought the "page unload" event would be perfect for this. However, it does not seem to work.
    I have no condition attached to the event. I have defined one true action to be fired, which executes a null pl/sql block and submits the main page items to save. This technique works fine in other cases, but in this case the page items do not get saved.
    According to firebug, I cannot even see the DA get triggered.
    Does anyone have any tips for this kind of DA event usage, or a better alternative technique?
    Thanks for any advice.
    Regards
    CS

    Add another JavaScript true action that fires before/after the PLSQL displaying an alert message so you know if the D.A is triggered.
    I created the same it seems to be working fine with redirects,page submits and even URL modification requests, and is showing the message before any page unload.

  • What can I use to list the specific web part types on a specific page?

    A user is trying to create a new entry on a sharepoint page. The page has various web parts showing bulleted lists of links.
    However, when he tried to create a new one, he ends up with the links having no bullets and the letters URL in a title bar over the links. The other link web parts do not have that.  The title bar allows sorting of the links; the other web parts have
    no title bar at all.
    This new web part has no "edit" option to modify parameters like titlebar, etc.
    Is there a powershell way that I could provide a URL and get the list of web parts, their types and their titles so that I could see what is going on and try to help him fix things?

    You can check all these out via the Web Part Maintenance Page. After the PageName.aspx, add ?contents=1 and you'll get a list of the webparts that are open and published on the page.
    You can't do too much here but you can reset the parts that you think might be causing the problems.
    Steven Andrews
    SharePoint Business Analyst: LiveNation Entertainment
    Blog: baron72.wordpress.com
    Twitter: Follow @backpackerd00d
    My Wiki Articles:
    CodePlex Corner Series
    Please remember to mark your question as "answered" if this solves (or helps) your problem.

  • Add Right Side Column and Web Parts to custom Master page in SharePoint Online

    Hello everyone, 
    I hope this is a simple question, however I was fighting the issue it presents for a while. I am in the process of customizing SharePoint Online Look-and-feel with a new layout.
    The site collection was created as a
    Team Site before I got involved with the project, and populated with numerous sub-sites and pages. I activated required
    publishing features, created html with corresponding styles and graphics, and used the Design Manager to convert the html file to the custom Master page. While SharePoint automatically assigned “ContentPlaceHolderMain” div area, I
    also used default Oslo page as example to copy sections of the code for dynamic components (left column and navigation, recent items, the ribbon, etc.) from it and placed them in my new master page, pointed all CSS references to
    my custom style sheets, etc. Everything works great, however I need to make one last addition -
    my task is to make changes to display web parts such as Calendar and Recent Documents in the right column in the Master page.
    My custom layout has a header, footer, main pan and two side columns. Most of the default master templates come with the LEFT column already embedded and populated with several placeholder
    to serve dynamic content (PlaceHolderLeftNavBarTop, PlaceHolderQuickLaunchTop, PlaceHolderLeftNavBarDataSource, PlaceHolderLeftActions, so on).
    My challenge is that I have the RIGHT side column as well, for which I don’t think the default placeholder exists. I need to add a small Calendar box and Recent Documents parts to it, so they
    display across the entire site governed by this master page.
    The issue is –
    even after activating Publishing features (enabled SharePoint Server Publishing Infrastructure under Site Collection Level, and SharePoint Server Publishing under the Site
    Level), there is no Snippet feature (usually available under the generic Publishing Site); this customization of the Team Site allows using Designer and apply custom templates, themes, so on, just like you would under the Publishing collection, but not the
    Snippet utility I could use as the solution to embed the web parts on the master page.
    Recreating the entire site under Publishing Collection is not an option due to the directions I was given, I am to use this existing one, and need to see if
    there is a workaround to either activate the Snippet feature or use another solution to display the web parts inside of the column in the Master page.
    If the only solution is to use Web Part Zone, what are the steps to add it AND populate it with the abovementioned apps?
    Can anyone suggest how to create a workaround and add this feature? The environment is role-based so both elements need to be dynamically rendered based on the user’s role and activities.
    I am more of a front end designer than developer, so if any custom coding and set up required, please kindly provide some basic steps, if possible?..
    I greatly appreciate any help and suggestions!
    Thank You!
    Jeff
    Jeff V.

    Updating your Master Page to also include a right rail should be sraight forward enough with a new div or divs in your master page and then the proper styles to make room for this column as well as position the column.
    I have not seen why you cannot find the snippet gallery link when previewing a HTML Master Page in the browser. Have you tried loading the snippet gallery by its url? As an example, for my tenant on SPO, I can load the Snippet Gallery for the olso.master
    with the following url:
    https://pixelmill.sharepoint.com/_layouts/15/ComponentConfigureControls.aspx?ComponentName=TopNavigationNoFlyoutWithStartNode&Url=%2F_catalogs%2Fmasterpage%2Foslo.master
    Change the domain to match yours as well as update the "Url" querystring var to point to your master page. See if that loads the snippet gallery.
    Eric Overfield - PixelMill -
    ericoverfield.com -
    @EricOverfield

  • Problems with some web parts when using XSLT

    I have a page on which I have several web parts. Some web parts are custom while others are OOB and only XSLT is applied on them.  
    I am using 2 WFEs with NLB. Problem is when I do iisreset on one of the WFE then the OOB web parts with XSLT start giving error. You know the standard error "corelation ID....bla bla bla". Anyway the error automatically goes away after a 2, 3 minutes.
    So basically if I do iisreset or stop the iis, and then load that page, then all custom web parts load fine except those OOB web parts with XSLT. And then they too start working fine after 2, 3 minutes if I reload page.  
    What could be the reason for that? Looks like some service on which XSLT depends take time to load!? And once that service is loaded then they start working fine?  Or it could be due to distributed cache or something!?

    Hi  Frank,
    Which version of the SharePoint 2010 did you use?
    In June 2011 CU code was added to the DataFormWebPart (which is used to display list data) that if an XSLT transform took longer than 5 seconds, a StackOverflowException was thrown. This was done to avoid
    a potential Denial Of Service attack on SharePoint if crafted XML could be sent that would continually clog up the XSLT, thereby stopping pages from rendering.
    In August 2011 CU the transform "timeout" was reduced from 5 seconds to 1.
    So, any list with XSLT that takes longer than 1 second to parse in an XSLT transform goes *boom*.
    After you perform an IIS reset , the cache of the page was cleared and you encountered the error. Once the page is cached, there is no error.
    You can try to set up XSLT Timeout with the following PS commands:
    $farm = Get-SPFarm
    $farm.XsltTransformTimeOut = 5
    $farm.Update()
    Reference:
    http://social.msdn.microsoft.com/Forums/sharepoint/de-DE/44cfd798-be7a-4436-8786-bd44049e7def/sp2010-column-filter-causing-unable-to-display-web-part-error-and-a-stack-overflow-exception?forum=sharepointgeneralprevious
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • SharePoint 2013 RSS Viewer not loading when other Custom web part using Update Panel or Ajax Timer control

    Hi,
    SharePoint 2013 RSS
    Viewer web part failing to complete loading when the page loads.
    This happens when having RSS Viewer and then adding a Custom webpart with an updatepanel and timer control.
    I  had used Ajax update panel and timer control to load the web part asynchronously after the main page is fully loaded.
    The RSS-Viewer web part hangs in loading state while the custom webpart loads just fine.
    The issue occurs when an like button click or Timer Tick event fires after the page
    is loaded.
    Haven't been able to track the issue.
    Couple of workaround I tried to call a server side button click event from the custom web part after the page gets fully loaded using JQuery shown below did not work out either.
     $(document).ready(function () {
                $('#<%= netButton2.ClientID %>').click();
    And 
    document.onreadystatechange = function () {
                if (document.readyState == "complete") {
                    $('#<%= netButton2.ClientID %>').click();
    Please let me know how to resolve this issue.
    Thanks,
    Franklin

    Hi Johan,
    The assignment of this user on the given task might be corrupted. Try to remove the resource from the task, publish the project, assign the resource again and publish again the project. If it is not working, try to unpublish the task (column "publish")
    and publih it again.
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

  • Wiki Pages - Open Web Part Page in maintenance view

    I am trying add custom .aspx pages to a SharePoint 2010 Document Library.  When I try to edit properties for those pages, the edit page shows "Open Web Part Page in maintenance view to delete problem Web Parts and remove personal settings.
    Open Web Part Page in maintenance view."  I click Open Web Part Page in maintenance view
    The page displays
    The are currently no Web Parts associated with any Web Part Zones on this page.  Web Parts added to the page outside of a Web Part Zone will not appear in this list.
    I don't do anything with the maintenance view because there are no Web Parts to delete.
    As a test, I save the content of the custom.aspx page as a text file, custom.txt.  The edit properties displays just fine.
    Another test, I save the content as custom.htm.  The edit properties displays just fine.
    I try many variations of saving the content of custom.aspx with various html tags and even no tags at all.  One version just has the text,"test" in the page.  Save error:
    Open Web Part Page in maintenance view to delete problem Web Parts and remove personal settings.  Open Web Part Page in maintenance view." 
    Going down another path, I try to compare the source of this aspx page with other SharePoint aspx pages.  One test is the Wiki Page.  All Wiki pages display the same message on my farm.  Is this a known issue with Wiki Pages?
    <apparently I'm not allowed to add images yet>
    As another point of comparison I opened the Edit Properties part within an Office 365 Wiki.  Same message.
    <apparently I'm not allowed to add images yet>

    Hi Chris,
    As your description, when you uploaded a .aspx page into a library and edited the properties, the message "Open Web Part Page in maintenance view to delete problem Web Parts and remove personal settings.  Open Web Part Page in maintenance view"
    showed.
    I could reproduce this issue if I uploaded a .aspx page into a library and edited its properties.
    Then I went to Site Pages library, and select a page and edit its property, the same message also showed like the screenshot:
    It seems that the message will show when we edit the properties of a page no matter which library we upload it to, it seems to be by design.
    In addition, if you want to upload a image into the thread, you can first upload the image into OneDrive, then copy and paste the URL of the image here.
    Thanks,
    Wendy
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

Maybe you are looking for

  • Book on HR ABAP , SAP-BW

    Hi All, Can anybody send me a good book for learning HR, PA, Payroll Abap, Its very urgent, Please send the same on my e-mail id [email protected] Also if u are able to send me a book on SAP-BW

  • Viewing Current Song in iTunes 10?

    Is there a command for iTunes to show you the song that's currently playing (show it highlighted in a visible list in the browser window)? Suppose it's on shuffle and you are separately doing stuff in iTunes like making a different playlist. Can you

  • Double Sided Printing through ePrint

    Hi, Tried searching the forum and this topic crops up a couple of times without any replies. Hence I'm assuming there's no way to set the default for documents sent via ePrint to be printed duplex (saving lots of paper). Any plans for an update to eP

  • Splitting a line in to two lines

    This is something that I would not even have questioned how to do, if i did not have a problem doing it. I can split a line in two quite happily in Text Edit, or this very text box that I am typing this post in, but Pages will not do it. I am typing

  • Sales Orders Assigned to Planned Independent Requirements

    Hello everyone I am trying to write an SQVI query which will show me which sales orders are confirmed against which planned independent requirement; so it will show the same data as MD73. Is there a table which links the sales order to the PIR? Thank