Passing Client value to server
I need to pass a client value to a server control. I use the code below:
------------- code start ----------------
1. <script language="JavaScript" type="text/javascript">
2. function StoreFileName(elem)
3. {
4. alert(elem.value);
5. var filename='<%=txtFileName.ClientID %>'
6. filename.value=elem.value;
7. alert(filename.value);
8. }
9. </script>
.
.
.
10. <input id="txtFileName" type="hidden" runat="server" />
------------- code end ----------------
When I run the code above, the alert on line 4 displays correct value, the alert on line 7 displays 'nothing'. I expect the filename.value in line 6 to have the same value as the elem.value. Does any one know what is wrong with this code and how can I pass this client value to the server?