hi,
this is solution without using Session :
protected override void OnPreRender(EventArgs e)
{
if (HttpContext.Current.Items["url"] != null)
((TextBox)dvwCategory.FindControl("txtImageUrl")). Text = (string)HttpContext.Current.Items["url"];
base.OnPreRender(e);
}
protected void UploadFile_Click(object sender, ImageClickEventArgs e)
{
if (filUpload.PostedFile != null && filUpload.PostedFile.ContentLength > 0)
{
try
{
// if not already present, create a directory named /Uploads/<CurrentUserName>
string dirUrl = (this.Page as EB.Eurobourse.UI.BasePage).BaseUrl +
"Uploads/" + this.Page.User.Identity.Name;
string dirPath = Server.MapPath(dirUrl);
if (!Directory.Exists(dirPath))
Directory.CreateDirectory(dirPath);
// save the file under the user's personal folder
string fileUrl = dirUrl + "/" + Path.GetFileName(filUpload.PostedFile.FileName);
filUpload.PostedFile.SaveAs(Server.MapPath(fileUrl ));
lblFeedbackOK.Visible = true;
lblFeedbackOK.Text = "File successfully uploaded: " + fileUrl;
HttpContext.Current.Items.Add("url", fileUrl);
}
catch (Exception ex)
{
lblFeedbackKO.Visible = true;
lblFeedbackKO.Text = ex.Message;
}
}
}
cheers.
|