M
Marko Vuksanovic
I am trying to notify a user of a fileUpload being in progress, in asp.net
page what I have done is:
1. created file upload control
2. created a button (id="upload") that runs a javascript that shows popup
and initiates button1 postback
3. button1 that should do the upload
the relevant code is below:
*.aspx
<asp:FileUpload id="FileUpload1" runat="server"> </asp:FileUpload>
<asp:Button id="Upload" Text="Upload file" runat="server"
OnClientClick="show_popup()"> </asp:Button>
<asp:Button id="Button1" OnClick="UploadButton_Click" runat="server"
Visible="false"> </asp:Button>
*.aspx.cs
public partial class FileUpload : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Upload.Attributes.Add("onClick", "__doPostback('" + Button1.ClientID +
"','');return false");
GetPostBackClientEvent(Button1, "");
}
protected void UploadButton_Click(object sender, EventArgs e)
{
String savePath = @"C:\Temp\uploads\";
if (this.FileUpload1.HasFile)
{
String fileName = FileUpload1.FileName;
savePath += fileName;
FileUpload1.SaveAs(savePath);
}
}
}
When I try to run the pag and do the upload Javascript throws the error
"Object expected", in the line where Button (id="Upload") is defined.... Any
ideas what I am doing wron?
Thanks, M.V.
page what I have done is:
1. created file upload control
2. created a button (id="upload") that runs a javascript that shows popup
and initiates button1 postback
3. button1 that should do the upload
the relevant code is below:
*.aspx
<asp:FileUpload id="FileUpload1" runat="server"> </asp:FileUpload>
<asp:Button id="Upload" Text="Upload file" runat="server"
OnClientClick="show_popup()"> </asp:Button>
<asp:Button id="Button1" OnClick="UploadButton_Click" runat="server"
Visible="false"> </asp:Button>
*.aspx.cs
public partial class FileUpload : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Upload.Attributes.Add("onClick", "__doPostback('" + Button1.ClientID +
"','');return false");
GetPostBackClientEvent(Button1, "");
}
protected void UploadButton_Click(object sender, EventArgs e)
{
String savePath = @"C:\Temp\uploads\";
if (this.FileUpload1.HasFile)
{
String fileName = FileUpload1.FileName;
savePath += fileName;
FileUpload1.SaveAs(savePath);
}
}
}
When I try to run the pag and do the upload Javascript throws the error
"Object expected", in the line where Button (id="Upload") is defined.... Any
ideas what I am doing wron?
Thanks, M.V.