Question about JavaScript and ASP.NET


Marko Vuksanovic

I am trying to notify a user of a fileUpload being in progress, in
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:
<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>

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;

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.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question