Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

System.NullReferenceException was unhandled by user code using Request.From in VS2008

While excuting the following code  with value for fn = "Location"; I received a System.NullReferenceException was unhandled by user code error and tbLocation was not null in the hidfilter.Value.


string ff = Utils.GetFilterFieldsCSV(Convert.ToInt32(ddTable.SelectedValue));
            hidfilter.Value = ff;
            string filtertxt = "";
           string [] filter = hidfilter.Value.Split(new Char [] {','});
           string itemsinVS = "";
          for(int i=0;i < filter.Length;i++) {
                     string fn = filter[i].ToString();
      string tbfn = "tb" + fn;
      string fv = Request.Form[tbfn].ToString();
      if (fv != "") {
            filtertxt += " " + fn + " LIKE('%" + fv.Trim().Replace("'", "''").Replace(";", "");
+ "%') AND";
                              itemsinVS += fn + ",";
                              ViewState[fn] = fv.Trim().Replace("'", "''").Replace(";", "");
                        }
                        else {
                              // remove existing value
                              ViewState[fn] = "";
                        }
                  }
0
keithwilson1
Asked:
keithwilson1
  • 2
  • 2
1 Solution
 
ChetOS82Commented:
It would help if you indicated where the exception was thrown.

Check the Request.Form collection for "tbLocation".
0
 
keithwilson1Author Commented:
The exception was thrown at
 string fv = Request.Form[tbfn].ToString();
0
 
ChetOS82Commented:
string fv = "";
if (Request.Form[tbfn] != null) {
     fv = Request.Form[tbfn].ToString();
}
0
 
keithwilson1Author Commented:
The problem was created by AJAX extensions but the Guru worked with me and I finally understood that I had to remove them.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now