Solved

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

Posted on 2011-09-04
2
269 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
Comment Utility
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
Comment Utility
thanks
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now