Watch this example on YouTube:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JavaScriptGetValueFromTheTextBox.aspx.cs" Inherits="WebApplication1.JavaScriptGetValueFromTheTextBox" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function getText() {
var str = document.getElementById('<%= TextBox1.ClientID%>').value;
alert(str);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="getText();" />
</div>
</form>
</body>
</html>
No comments:
Post a Comment