Solved

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

Posted on 2011-09-04
2
272 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
2 Comments
 
LVL 35

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

773 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