web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to catch the standard browser ”Back” (Alf+Left in IE) button event?

(0) ShareShare
ReportReport
Posted on by 735

Hi All,

I have the following scenario: I have a parent page, where I have a filtered set of records and one of the grid’s field is AxHyperLinkBoundField, so clicked on it will open a child page with some details info, but when the user clicks the standard browser ”Back” (Alf+Left in IE) button, the filter on the parent page is gone.

1651.1.jpg

So, I have a question: How to catch the standard browser event, when user clicks the ”Back” (Alf+Left in IE) button?

I have found just this proposition https://msdn.microsoft.com/en-us/library/cc518834.aspx

and some another example in TSTimesheetApproval control, but I didn’t found how does it called by the clicking of the ”Back” (Alf+Left in IE) button

private void RedirectToPreviousPage()

{

   if (DialogHelper.IsCurrentPageModalDialog() == true)

   {

       // Page is displayed in a modal dialog, so close the page.

       DialogHelper.Close();

   }

   else

   {

       // Page is opened in the main browser, so try to return to the previous page.

       if (!String.IsNullOrEmpty(AxWebSession.GetPreviousURL(this.Page)))

       {

           Response.Redirect(AxWebSession.GetPreviousURL(this.Page));

       }

       else

       {

           // The previous page is not available, so return to a known page.

           // Use the URL Web Menu item from the AOT to specify which

           // page will be displayed.

           AxUrlMenuItem listpage = new AxUrlMenuItem("FCMWorkOrdersListPage");

           Response.Redirect(listpage.Url.OriginalString);

       }

   }

}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Iulian Cordobin Profile Picture
    8,201 on at

    My question is, the child form that is opening as a result of clicking the AxHyperLink is not by any chance a 'pop-up page' displayed on top of the browser (called Modal WindowMode), meaning that you still see in the background the main page?

    From a standard implementation point of view, this would be the proper way (to maintain the same UI behavior over the entire EP), and in this case, you do not need to press the Back button in the browser. Simply clicking the close 'x' button on this window will close it and will return to the initial page (as well as pressing Esc) - be careful not to close the browser.

  • Ragoza Oleksandr Profile Picture
    735 on at

    Hi Iulian,

    No, the child form, that is opening, is not a 'pop-up page' displayed on top of the browser, it was developed separately from parent page in another modification. As far as I understood, if it was (a 'pop-up page' displayed on top of the browser), the standard approach is applicable (I mean the snippet of code that I showed in my question), but in my case – no, it's not.

    So, any ideas? :)

  • Verified answer
    Iulian Cordobin Profile Picture
    8,201 on at

    Well, a few but I am not sure which ones may apply.

    Basically, even if you catch the Back event, although I am not sure how easy this can be done (never done it), you are not close to resolve your reload issue. My question at this moment is what feature are you actually using in setting the filters? Is the page having The ViewState enabled? Because this is how you would store this information, and this is how the browser would reload your page. I think this is the key.

  • Ragoza Oleksandr Profile Picture
    735 on at

    Responses on your queries:

    1. what feature are you actually using in setting the filters

    I have a panel

    <asp:Panel ID="Panel1" runat="server" DefaultButton="btnSearchSubmit">

    <div id="searcharea" class="s4-search dynFloatLeftForLTR">

     <div id="divSearchTextBox" class="dynFloatLeftForLTR">

       <asp:TextBox ID="txtSearch" runat="server" Text="" size="25" name='SearchString'

           class="ms-searchbox"

           display='inline' MaxLength="255" AccessKey="S" ToolTip="<%$ AxLabel:@CRM1710 %>">

       </asp:TextBox>

     </div>

       <div class="ms-searchimage dynFloatLeftForLTR">

           <span style="height:13px;width:13px;position:relative;display:inline-block;overflow:hidden;">

               <a target='_self' href='javascript:' runat="server" onserverclick="SearchButton_Click"

                   title="<%$ AxLabel:@CRM1129 %>" accesskey="O" id="aSearchButton" style="display:inline-block;height:13px;width:13px;" >

                   <img src="/_layouts/images/fgimg.png" alt="Search" class="dynCatSearchControlImage" />

               </a>

               <asp:ImageButton runat="server" ID="btnSearchSubmit" ImageUrl="/_layouts/images/GOSEARCH.GIF" OnClick="SearchButton_Click" Visible="true" Height="0" Width="0"/>

           </span>

       </div>

    </div>

    </asp:Panel>

    <br />

    <br />

    In the code behind I call a method on dataset

    protected void SearchButton_Click(object sender, EventArgs e)

       {

           if (VINfilter != null)

           {

               txtSearch.Text = VINfilter;

           }

           this.ReestrClaimVINHistoryDS.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call("setVINRange", String.IsNullOrEmpty(txtSearch.Text) ? "none" : txtSearch.Text);

       }

    And then I add range to the query by _ds.executeQuery()

    2. Is the page having The ViewState enabled?

    Both properties of the control (EnableViewState and ViewStateMode) are empty (I'm not sure if it's true, false or disabled).

    Making a conclusion from your coments, I assume that the output and time that I will spend to realize this (my) idea will not worth that.

    So, thank you for your comments, I think that requirement should be changed and child form should be opened in modal view.

  • Verified answer
    Iulian Cordobin Profile Picture
    8,201 on at

    Thinking further on this item, what you would be using in the case of the Back button would be the cache of the browser, and from what is looks like, the pages on EP are being requested / served with a no-cache / max-age=0 / cache-control private header, which means that no content is being stored and every time the page is to be displayed it will ve asked from the server. So, the fix, as you said just implement the pages as model windows.

  • Ragoza Oleksandr Profile Picture
    735 on at

    Ok, Iulian, thanks for advice!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans