I have a single textbox txtUser where a user can input a username, and there is a Delete button beside this textbox. I am providing a delete confirmation using the OnClientClick attribute of the <asp:button>.
The message is: Are you sure you want to delete this user? This works.
I want to change this message to Are you sure you want to delete 'username'? by getting the value of the username from the textbox using the GetElementByID("<%= txtUser.ClientID %>") and storing it in a variable user
<script type="text/javascript">
var username = document.GetElementByID(<%= txtUser.ClientID %>")
</script>
Now I want to use this username variable in the OnClientClick call. I tried something like this, but it didn't work:
<asp:Button ID="BtnDelete" runat="server"
OnClientClick="return confirm('Are you sure you want delete "+username+"');">
Delete</asp:Button>