Solved

Why does my 2nd query string parameter always come up null?

Posted on 2011-09-04
2
278 Views
Last Modified: 2012-05-12
I'm trying to pull a 2nd query string parameter value in as a property to a user control, for some reason it is always coming up null. I think it has something to do with the way i'm constructing my redirect string but i'm not sure. below is the the redirect url, and the properties as i'm trying to get / set them. can someone show me what's wrong with what i'm doin.
Response.Redirect(String.Format("/StudentTime.aspx?AddEdit={0}&SearchBy={1}", addEdit, "FirstAndLastName"));

---my properties GET / SET---

    public String AddEdit
    {
        get
        {
            m_addedit = Request.QueryString["AddEdit"];
            return m_addedit;
        }
        set
        {
            m_addedit = value;
        }
    }

    public String SearchBy
    {
        get
        {
            m_searchby = Request.QueryString["SearchBy"];
            return m_searchby;
        }
        set
        {
            m_searchby = value;
        }
    }

---THE INITIAL IF BELOW ALWAYS FAILS--
        if (!string.IsNullOrEmpty(SearchBy))
        {
            if (string.Equals(SearchBy, "FirstAndLastName"))
            {
                iobl = InOutListProcessor.GetInOutRecsByStudentName(SearchBy);
                //iobl.Add(iob);
            }
            if (string.Equals(SearchBy, "StudentID"))
            {
                iob = InOutListProcessor.GetInOutRecsByStudentID(SearchBy);
                iobl.Add(iob);
            }
            if (string.Equals(SearchBy, "TeamName"))
                iobl = InOutListProcessor.GetInOutRecsByTeamName(SearchBy);
        }

Open in new window

0
Comment
Question by:mikesExpertExchange
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 36482174
Is your AddEdit values contains blank spaces or &?
If so you need to use Server.UrlEncode before adding parameters
Response.Redirect(String.Format("/StudentTime.aspx?AddEdit={0}&SearchBy={1}", Server.UrlEncode(addEdit), "FirstAndLastName"));


Check:
http://www.codeproject.com/KB/aspnet/QueryString.aspx
0
 
LVL 1

Author Closing Comment

by:mikesExpertExchange
ID: 36486204
thanks
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question