Ticket Q403338
Visible to All Users

Passing parameter in QueryString

created 13 years ago

Hi!
I try add parameter to query in controller by next way:
HttpContext.Current.Response.Redirect((string.Format("DefaultVertical.aspx#ShortcutViewID=SaleItem_ListView_PurchaseSummary&ClientOrderID={0}&ShortcutObjectClassName=Databutikken.ERP.Module.BusinessObjects.SaleItem", currentOrder.OrderId)));
I want filtering collection in ListView by this parameter
But when the page download, parameter is not present in query string, and I can not filtering collection

Answers

created 13 years ago (modified 13 years ago)
    created 13 years ago (modified 13 years ago)

    It does not seem to be related to DevExpress controls but here's the answer anyway: replace the # symbol with ?.

    Also you might want to encode your URL with HttpServerUtility.UrlEncode first.

      created 13 years ago (modified 13 years ago)

      Hello Roman,
      You cannot easily process Get parameters in a controller, because the query string is modified by XAF HTTP handler. If you wish to pass an additional information to the XAF view outside the XAF application, add this information to the ViewShortcut (e.g. add the ShortcutClientOrderID parameter to the query string) and get it in the XafApplication.CustomProcessShortcut event handler.
      If you need to pass something to a view inside the XAF application, do not use the Redirect method. Instead of this, show view via the ShowViewStrategy.ShowView method, as shown in the How to invoke a View without using Actions or from a place that is different from the Controller context article.

        Show previous comments (1)
        Anatol (DevExpress) 13 years ago

          When the browser's Refresh button is clicked, the ListView is restored from the shortcut, and since the shortcut does not contain the collection source's criteria, the latter is lost. To solve this problem, store criteria somewhere, e.g. in cookies or in the view's model, and restore it when the view is shown. The easiest way to do this is to use the model's Criteria property - in this case it is be required to restore criteria manually. To avoid changing the default Book_ListView, create a copy and use it as the model of the shown view. Here is an example:

          C#
          IObjectSpace os = Application.CreateObjectSpace(); CollectionSourceBase cs = Application.CreateCollectionSource(os, typeof(Solution1.Module.BusinessObjects.Book), "Book_ListView_Copy"); IModelListView listViewModel = (IModelListView)Application.Model.Views["Book_ListView_Copy"]; listViewModel.Criteria = "Author_ID.ID = " + author.ID.ToString(); e.ShowViewParameters.CreatedView = Application.CreateListView(listViewModel, cs, true);
          RS RS
          Roman Shelomanov 13 years ago

            It works. Thank you!

            Anatol (DevExpress) 13 years ago

              You are welcome!

              Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

              Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.