1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Cant access news querystrings

Cant access news querystrings

5 posts, 0 answered
  1. Roberto
    Roberto avatar
    146 posts
    Registered:
    08 Feb 2008
    02 Mar 2010
    Link to this post
    Hi,

    I am trying to work with news module and cant seem to access the querystring values for some reason.  Attached is the screen for the news view control (article views are displayed on a different page with these same settings).  When i try and access the query string (i am doing if from a class in the APP_CODE as this where i need to use this logic)  i receive nothing??

    nothing fancy with the code:

    string test = HttpContext.Current.Request.QueryString["category"] != null ? HttpContext.Current.Request.QueryString["category"] : "aaa";
    HttpContext.Current.Response.Write(test);

    i get a lot of aaaaaa but not category names, can anyone see what i have done wrong, i am using SF3.7.

    Thanks,

    Rob

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    02 Mar 2010
    Link to this post
    Hello Roberto Modica,

    The code you have seems to be correct. Most probably there is not querystrings collection at the time you are trying to get the keys.

    1. Check whether there are any keys in the NameValueCollection. If not move the code in the proper lifecycle place.

    string[] k = Context.Request.QueryString.AllKeys;

    2. The following code works if you execute it OnPreRender of a control

    string key = (Context.Request.QueryString["category"]);
    if (!String.IsNullOrEmpty(key))
    {
        string t = key;
        Response.Write(t);
    }


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Roberto
    Roberto avatar
    146 posts
    Registered:
    08 Feb 2008
    02 Mar 2010
    Link to this post
    Hi Ivan,

    This code is overriding the InitializeItem of the breadcrumb control, i have been using items from the query string to perform other tasks in this method (such as find locations and products and change text) so it seems that it is specifically the news querystrings that are not being sent.

    I have a news view on a page, that sends the job of rendering individial news results to another article view page, the article renders fine, but i need to do some work with the breadcrumb control to go back to the page it came from, and need to replace the text "article view" with that of the news category.

    I know that querystrings are available at the point this method gets called as i use them, but for some reason the news ones are just not being passed????

    Rob
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    02 Mar 2010
    Link to this post
    Hello Roberto Modica,

    I created a sample BreadCrumb control and got the QueryString in InitializeItem. Here is the code I used. You will find attached a sample video that illustrates the result.


    public class Class3 : Breadcrumb
    {
        public Class3()
        {
        }
     
        protected override void InitializeItem(System.Web.UI.WebControls.SiteMapNodeItem item)
        {    
            string key = (Context.Request.QueryString["category"]);
            if (!String.IsNullOrEmpty(key))
            {
     
            }
        }
    }

    Note that the category QueryString is added to the url when you click on categories link and the url
    http://localhost:2889/emptyproject/filesupload.aspx?category=39ab0225-1cf3-4d37-94df-2b7a53c59839 or if you explicitly set the QuryString and make rewriting.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Roberto
    Roberto avatar
    146 posts
    Registered:
    08 Feb 2008
    03 Mar 2010
    Link to this post
    Hi Ivan,

    This didnt work for me, maybe becuase i am not clicking on the category view, i am simply using a news view to display a list and then going to a different page to view the actual article.  I have got around this issue by just hacking up the url and taking the category out of there and working with it on that bases, not the cleanest approach and not one i really like doing but it is working and allows me to progress with the project.

    Rob
Register for webinar
5 posts, 0 answered