ASP Upload and localization

The Asp.Net (or in general html) file upload control displays the text "Browse". There is no attribute which allows controlling the text displayed. This goes against the localization principals which says every text/label may appear in local language.

I did the following workaround...

(Is there any simpler workaround... Your suggestions are welcome)

===Explanation===
Basically I hide the actual upload control and instead use proxy controls which look similar to the ones rendered by the browser and are localized. I have used javascripts to hook up required events to make it work like an exact original browser one.

====ASPX file====
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="FileUpload._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script language=javascript>
function BubbleUploadClick()
{
document.all("FileUploadImage").click();
}

function FileUploadOnChange()
{
document.all("TextBoxCopyFilePath").value = document.all("FileUploadImage").value;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="FileUploadImage" runat="server" style="display:none" onchange="FileUploadOnChange()"/><br />
<asp:TextBox ID="TextBoxCopyFilePath" runat="server" Width="259px" ReadOnly="true"></asp:TextBox>
<asp:Button ID="ButtonUploadFiles" runat="server" Text="Upload Files" OnClientClick="BubbleUploadClick();return false;" />
<asp:Button ID="ButtonSubmit" runat="server" />
</div>
</form>
</body>
</html>

Comments

Popular posts from this blog

Dirty workarouds: dirty page checking + AJAX