How to get the value of textbox in JavaScript in asp.net

get the value of textbox in JavaScript in asp.net

<!DOCTYPE html>
<html>
<head>
<script>
// access the value of the above textbox
 var name = document.getElementById('<%=txtFriendName.clientID%>').value;
 alert(name);
</script>
<head>
<body>
Friend name: <asp:TextBox ID=" txtFriendName " runat="server" Text ="Sachin Tendulkar"></asp:TextBox>
</body>
</html>

 

Leave a Reply