Last post Mar 04, 2019 01:18 PM by mgebhard
Mar 04, 2019 01:08 PM|Enzyme|LINK
I have an issue here, were I want to register user with referrer link, first it will check if the referrer link supplied by user is valid, if it is valid it will register user, if it is invalid it will
alert user of invalid referrer link, but if the referrer link is not supplied it will tell user to use valid referrer link.
below is my code
A) The Default page code behind
protected void Page_Load(object sender, EventArgs e)
var trackerRef = Request.QueryString["ref"]; // Catching the referre Link
Session["RefID"] = trackerRef;
The Register page code behind
protected void CreateUser_Click(object sender, EventArgs e)
if (!object.Equals(Session["RefID"], null)) // Catching the referrer Link
string refId = Session["RefID"].ToString();
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbConn"].ToString());
SqlCommand cmdd = new SqlCommand("CheckRefId", con);
SqlDataAdapter adp = new SqlDataAdapter();
cmdd.CommandType = CommandType.StoredProcedure;
cmdd.Parameters.Add("@RefCheck", SqlDbType.NVarChar).Value = refId ;
cmdd.Connection = con;
adp.SelectCommand = cmdd;
if (object.Equals(Session["RefID"], null))
lbl1.Text = "You need a valid Referrer Link!";
else if(dt.Rows.Count < 1)
lbl1.Text = "Referrer Link is not a valid Link!";
else if (dt.Rows.Count > 0)
// Register User
with the above code when referrer link is supplied, it determines if referrer link is valid, and it works well, but when referrer link is not supplied message in lbl1 in above highlighted code does not respond.
please how do I restructure my code so that if referrer link is not supplied the lbl1 message in highlighted part of the code will respond.
Mar 04, 2019 01:18 PM|mgebhard|LINK
The syntax is pretty simple.
if(Session["RefID"] == null)
If this does work then you have bugs to find. Please use the Visual Studio debugger to check your code.
Keep in mind that the Page_Load event always fires before the click handler.