SlickUpload
Welcome Guest Search | Active Topics | Log In | Register

file.getElementById Not Working Options
chrisajohn
#1 Posted : Monday, November 16, 2009 10:26:59 AM
Rank: Newbie

Groups: Registered

Joined: 11/10/2009
Posts: 8

Our clients have a requirement where they want to see an icon next to each file uploaded that shows the file type (pdf, word, etc).  I am trying to use the file.getElementById function on the OnClientFileAdded method. 

Here is a portion of the "AddFile" method:

    function <%= ClientID %>_addFile(file) {

        //get the file selector
        var fileUpload = kw.get('<%= fsSelector1.ClientID %>');
        var files = fileUpload.get_Files();
       
        //set the extension image
        var imgExt = file.getElementById("imgFileExt");
       
        var strFileExt = file.extension;
        if (strFileExt.toLowerCase() == "docx")
        {
            strFileExt = "doc";
        }
        if (strFileExt.toLowerCase() == "pps")
        {
            strFileExt = "ppt";
        }
        if (strFileExt.toLowerCase() == "xlsx")
        {
            strFileExt = "xls";
        }
        var strImg;
        switch (strFileExt.toLowerCase())
        {
            case "doc": case "dwf": case "dwg": case "jpg": case "pdf": case "ppt": case "rvt": case "tif": case "xls": case "zip":
                strImg = "/images/button_" + strFileExt + ".gif";
                break;
            case "pptx": case "pptm":
                strImg = "/images/button_ppt.gif";
                break;
            default:
                strImg = "/images/button_unknowntype.gif";
                break;
        }
        imgExt.src = strImg;

.....

Here is the fileList code:

        <kw:FileList ID="fl" runat="server">
            <FileTemplate>
                <kw:FileListRemoveLink ID="FileListRemoveLink1" runat="server" Title="Remove">
                    <img src="/images/close.gif" border="0" />
                </kw:FileListRemoveLink>
                &nbsp;&nbsp;&nbsp;<kw:FileListFileName ID="FileListFileName1" runat="server" />
                &nbsp;&nbsp;&nbsp;<img id="imgFileExt" />
                <kw:FileListValidationMessage ID="FileListValidationMessage1" runat="server" ForeColor="Red" />
            </FileTemplate>
        </kw:FileList>

When I add a file, it gives me a "imgExt is null"error.

This is our last hurdle for this new release.  Thanks for such a great product!

chrisajohn
#2 Posted : Wednesday, November 25, 2009 12:45:50 PM
Rank: Newbie

Groups: Registered

Joined: 11/10/2009
Posts: 8
Any update on this one?
Thanks!
Axosoft
#3 Posted : Friday, November 27, 2009 1:23:57 PM
Rank: Administration


Groups: Administrators

Joined: 7/7/2005
Posts: 1,586
Location: Scottsdale, AZ

Can you email your .aspx and codebehind to chrish at krystalware dot com? We've tested several configurations based on the snippet you sent and we haven't been able to reproduce the issue.

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.