-1

I have an aspx page head section containing the following javascript function:

<script type="text/javascript">
    function addFile() {
        var table = document.getElementById("filesTable");
        var row = table.insertRow(0);
        var cell1 = row.insertCell(0);
        var cell2 = row.insertCell(1);
        cell1.innerHTML = document.getElementById('hImageLoc');
        cell2.innerHTML = document.getElementById("hFileName");
    }
</script>

I got the code from a site called aspsnippets.

The hImageLoc and hFileName are both asp:Hidden fields on the aspx page. The user selects a file from a FileUpload control and then clicks an upload button (asp:Button). In the code behind (VB.Net) I have some code which saves the file and this works fine.

After the code has processed this far, and the file has been saved, I want to call the JavaScript function above, which will add a line to an HTML table with the name and document type.

I just can't seem to figure out how to call the JavaScript at that point in the VB code. Can someone point to an article or place that would have a clear example of how to do this?

Paul
  • 4,160
  • 3
  • 30
  • 56
mbcharney
  • 355
  • 1
  • 4
  • 15

1 Answers1

1

You're actually heading down the wrong path.

What may be more beneficial to you is to add a data driven table, such as a DataList, GridView or Repeater to your form and set-up a data connection to display the information.

Each have their own pro's and con's, but the link I've given will give you some insight.

When you upload and 'save' your files your page will have to perform a postback. Depending on how you do this, the control you choose will update itself regardless.

There are some good tutorials around that will help you do the job...

The UpdatePanel - Very useful for performing updates to your page instantly, rather than having to postback the entire page.

The DataList and Repeater Controls - Useful for displaying repetitive data.

The GridView Control - Useful for providing a limited editing facility for your data.

Paul
  • 4,160
  • 3
  • 30
  • 56