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>
<kw:FileListFileName ID="FileListFileName1" runat="server" />
<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!