Question about JavaScript and ASP.NET

Discussion in 'ASP .Net' started by Marko Vuksanovic, Jul 28, 2006.

  1. 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.
    Marko Vuksanovic, Jul 28, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Virgil Hobbs
    Replies:
    0
    Views:
    499
    David Virgil Hobbs
    Jan 6, 2004
  2. Marko Vuksanovic

    Question about JavaScript and ASP.NET

    Marko Vuksanovic, Jul 28, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    995
    Marko Vuksanovic
    Jul 28, 2006
  3. Bit Byte
    Replies:
    1
    Views:
    818
    Teemu Keiski
    Jan 28, 2007
  4. Thomas

    ASP.NET - VB.NET - JavaScript Question

    Thomas, Dec 3, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    236
    Jorge Ponte
    Dec 19, 2004
  5. Amelyan
    Replies:
    2
    Views:
    122
    Amelyan
    Apr 25, 2005
Loading...

Share This Page