While developing Web Application in ASP.NET some time you need to interact your .aspx page with html view of the web page. To do so we need to use a JavaScript function. Using JavaScript function we can easily pass values from Javascript function to ASPX. In this article I am going to share the easiest way to pass value from JavaScript Function to ASPX page. Also with this information I am sharing a demo project that will help you to perform the task easily.
Free Download: JavaScript to ASPX : Demo Project
Source Code of Web Page
<head runat=”server”>
<script type="text/javascript"> function abc() { var str = "Mark"; document.getElementById("txtName").value = str; } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label> <asp:Label ID="Label2" runat="server" Text=":"></asp:Label> <asp:TextBox ID="txtName" runat="server"></asp:TextBox> <asp:Button ID="btnshow" runat="server" Text="show" OnClientClick="abc()"/> </div> </form> </body>
