I want to get the value of textbox that a user enters. Below is the code snippet of aspx page :
<asp:TextBox id="txtUserName" runat="server" />
Now which is the best way to access DOM object in aspx page
1.
<script type="text/javascript">
var value= document.getElementById(<%= txtUserName.ClientID %>).value;
alert(value);
</script>
<script type="text/javascript">
var value= document.getElementById(<"txtUserName""txtUserName").value;
alert(value);
</script>