i am using session and very working fine but when i upload the picture and press button it redirect to login.aspx...
dont know why this is happing
protected void Page_Load(object sender, EventArgs e)
{
string username = (string)(Session["UserAuthentication"]);
if((Session["UserAuthentication"]!=null) && (!Page.IsPostBack))
{
Label2.Text=username;
string query ="SELECT Node,Title, Source, Scope, Criticality, Vendor, Dependancy, Status, [Start Week], ID, Resource FROM ['2013 Projects$'] WHERE Resource='" + username + "'";
da = new SqlDataAdapter(query, connstring);
dt = new DataTable();
da.Fill(dt);
GridView3.DataSource = dt;
GridView3.DataBind();
}
else
{
Response.Redirect("Login.aspx");
}
if (!Page.IsPostBack)
{
tasks();
}
}
protected void Button2_Click1(object sender, EventArgs e)
{
StartUpLoad();
}
private void StartUpLoad()
{
string imgName = "default.jpg";
string imgPath = "Images/gallery/adil/" + imgName;
int imgSize = FileUpload1.PostedFile.ContentLength;
if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "")
{
if (FileUpload1.PostedFile.ContentLength > 102400)
{
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Alert", "alert('File is too big.')", true);
}
else
{
FileUpload1.SaveAs(Server.MapPath(imgPath));
Image1.ImageUrl = "~//" + imgPath;
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Alert", "alert('Image saved!')", true);
}
}
}