3 Replies - 1822 Views - Last Post: 21 September 2009 - 11:21 PM Rate Topic: -----

#1 looper  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 26-August 09

Where do i put my response.redirect

Posted 11 September 2009 - 09:49 PM

hey, in my code have a login and another sql query which retrieve something from facebook but i do not know where to put my Response.Redirect("~/Profile2.aspx"); i put it at the login place it cannot retrieve that something from facebook. And if i put it at the bottom anything value i insert can log in to the next page.

this is my code
namespace facebookDemo
{
	public partial class Verification2 : System.Web.UI.Page
	{
		public string name;
		public string caregroupID;
		public string staffNumber;
		//public string name2;
		public string uid;
		



		protected void Page_Load(object sender, EventArgs e)
		{
			if (Request.Cookies["txtMatricNo"] != null && Request.Cookies["txtSCardNo"] != null)
			{
				txtMatricNo.Text = Server.HtmlEncode(Request.Cookies["txtMatricNo"].Value);
				txtSCardNo.Text = Server.HtmlEncode(Request.Cookies["txtSCardNo"].Value);
			   //btnProceed2_Click;
				
			}
		}

		protected void btnProceed2_Click(object sender, EventArgs e)
		{
			
			if (CheckBox1.Checked == true)
			{
			   /* if (Request.Cookies["txtMatricNo"] != null && Request.Cookies["txtSCardNo"] != null)
				{
					Response.Cookies["txtMatricNo"].Expires = DateTime.Now.AddDays(-1d);
					Response.Cookies["txtSCardNo"].Expires = DateTime.Now.AddDays(-1d);
				}*/
				Response.Cookies["txtMatricNo"].Value = txtMatricNo.Text;
				Response.Cookies["txtSCardNo"].Value = txtSCardNo.Text;
				Response.Cookies["txtMatricNo"].Expires = DateTime.Now.AddSeconds(50);
				Response.Cookies["txtSCardNo"].Expires = DateTime.Now.AddSeconds(50);
			}
			try
			{
				string connectString = ConfigurationManager.AppSettings["DatabaseConnectionString"];
				SqlConnection con = new SqlConnection(connectString);
				con.Open();
				string thesql = "select * from student where studMatricNumber='" + txtMatricNo.Text + "' and  studCardNumber = '" + txtSCardNo.Text + "';";
				SqlCommand cmd = new SqlCommand(thesql, con);
				SqlDataReader reader = cmd.ExecuteReader();

				while (reader.Read())
				{

					//name2 = reader["uid"].ToString();
					//Session["name2"] = name2;
					name = reader["studName"].ToString();
					Session["name"] = name;
					caregroupID = reader["caregroupID"].ToString();
					Session["caregroupID"] = caregroupID;
					uid = reader["uid"].ToString();
					Session["uid"] = uid;
					
					//Response.Redirect("~/Profile2.aspx");
				}
				reader.Close();
				con.Close();

			}
			catch (Exception err)
			{

				// myLabel2.Text = "Error: " + err;
			}
			try
			{


				string connectString2 = ConfigurationManager.AppSettings["DatabaseConnectionString"];
				SqlConnection con2 = new SqlConnection(connectString2);
				con2.Open();

				string thesql2 = "Update student set uid ='" + Facebook.Web.FacebookHttpContext.Current.Session.Uid + " 'WHERE studMatricNumber='" + txtMatricNo.Text + "'";
				
				//Update Student set studEmail ='l;jkkljhj' , studhandphone='3213231' WHERE studName  ='lionel lau'
				SqlCommand cmd2 = new SqlCommand(thesql2, con2);

				cmd2.ExecuteNonQuery();



				con2.Close();
				Response.Redirect("~/Profile2.aspx");
			}
			catch (Exception err)
			{
				//myLabel.Text = "Error: " + err;
			}
			Response.Redirect("~/Profile2.aspx");

		}


	  
		


	}
}




Is This A Good Question/Topic? 0
  • +

Replies To: Where do i put my response.redirect

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5957
  • View blog
  • Posts: 23,226
  • Joined: 23-August 08

Re: Where do i put my response.redirect

Posted 12 September 2009 - 07:19 AM

Looks like ASP.NET to me. Moving.
Was This Post Helpful? 0
  • +
  • -

#3 looper  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 26-August 09

Re: Where do i put my response.redirect

Posted 12 September 2009 - 06:36 PM

anyone can help me? where should i put my Response.Redirect("~/Profile2.aspx");
to get the best of both method.
Was This Post Helpful? 0
  • +
  • -

#4 carle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 21-September 09

Re: Where do i put my response.redirect

Posted 21 September 2009 - 11:21 PM

Hey,

Response.Redirect("~/Profile2.aspx",false);


Carle
__________________
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1