I have a file called Upload that is used to upload images. Other files then call this Upload file. The problem is I need to know which upload button was clicked, because one button needs to save the images in a different path file than the other upload buttons. I tried creating a session but the session was being created each time the page was loaded so that won't work. The code that handles the upload is in an iframe. When I click the upload button, the iframe appears which gives the option to select a file from your computer and upload it. I need to pass a value from the ShowUploadImage() function to the iframe so I know which upload button was clicked.
This is code behind the upload button:
function ShowUploadImage() {
$('#dvAddEditImage').fadeIn(300);
$("#dvAddImage").html("<img src=\"images/loading.gif\" alt=\"Loading...\" title=\"Loading...\" />");
$("#dvAddImage").fadeIn(300);
$("#dvAddImage").html("<iframe id=\"iframeUpload\" src='utilities/UploadPOD.aspx'></iframe>");
Session["Session"] = "Upload";
}
I added the Session to Page_Load. But now the session is created every time which isn't what I need.
protected void Page_Load(object sender, EventArgs e)
{
Session["Session"] = "Upload";
}
}
Then in the Upload file I need to check which button was clicked:
if (fuUpload.HasFile)
{
string JobType = Convert.ToString(Session["Session"]);
Session["Session"] = null;
if (JobType == "Upload")
{
}
else
{
}
}
Maybe using a session isn't the right way to do this? How do I pass a value over between different code files?
EDIT
Ok added a hidden field:
<asp:HiddenField ID="hfSession" runat="server" Value="Upload" />
And added to the upload button:
function ShowUploadImage() {
$('#dvAddEditImage').fadeIn(300);
$("#dvAddImage").html("<img src=\"images/loading.gif\" alt=\"Loading...\" title=\"Loading...\" />");
$("#dvAddImage").fadeIn(300);
$("#dvAddImage").html("<iframe id=\"iframeUpload\" src='utilities/UploadPOD.aspx'></iframe>");
document.getElementById('<%= hfSession.ClientID %>').value = "Upload";
}
So how do I call this hidden field in the other page file. These 2 files have no connection so how is the value of the hidden field going to be passed?