Hi:
I get an (object reference not set to an instance of an object) error when I use a PostBackUrl as a method to pass data between pages. Please see following code. The code in red is highlighted in the error. This error occurs infrequently and seemingly randomly.
page 1------
codebehind for page 2------
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string previouslogin;
previouslogin = ((TextBox)PreviousPage.FindControl("logintxt")).Text;
.
.
.
.
.
.
}
}
}
Loading
Craig DavisPosted Apr 20, 2011, 10:30 PM
Suthish NairPosted Apr 20, 2011, 4:58 PM
if (Page.PreviousPage != null) {
DropDownList ddl = (DropDownList)Page.PreviousPage.FindControl("ddl1");
if (ddl != null) {
lbl4.Text = ddl.SelectedItem.Text;
lbl4.ForeColor = System.Drawing.Color.FromName(lbl4.Text); } }
Ankit NandekarPosted Apr 20, 2011, 10:52 AM