Here is the solution,
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
<script type="text/javascript">
var obj = document.getElementById("TextBox1");
var newObj = document.createElement('input');
newObj.setAttribute('type', 'password');
newObj.setAttribute('id', obj.getAttribute('id'));
newObj.setAttribute('name', obj.getAttribute('name'));
obj.parentNode.replaceChild(newObj, obj);
newObj.focus();
</script>
The basic idea is to create a new element with your desired textmode and replace the original with the new one.
Hope this helps.
cheers