Solved

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

Posted on 2011-09-04
2
276 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Finding Events logs for IIS website that restarts 2 14
IEnumerable<T> to a List<T> 8 37
abstract class C# 1 31
Google Maps with Webforms 1 12
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

840 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