asp.net - Getting Textbox value in Javascript -


i trying value of textbox in javascript, not working. given below code of test page

<%@ page title="" language="vb" masterpagefile="~/site.master" autoeventwireup="false" codefile="test3.aspx.vb" inherits="test3" %>  <asp:content id="content1" contentplaceholderid="headcontent" runat="server"> <script language="javascript">      function getalert() {          var testvar = document.getelementbyid('txt_model_code').value;         alert(testvar);      }  </script> </asp:content> <asp:content id="content2" contentplaceholderid="maincontent" runat="server"> <asp:textbox id="txt_model_code" runat="server" ></asp:textbox><br /><br />  <input type="button" value="db function" onclick="getalert()" /><br /> </asp:content> 

so going wrong?? how text entered in textbox in javascript???

use

document.getelementbyid('<%= txt_model_code.clientid %>') 

instead of

document.getelementbyid('txt_model_code')` 

also can use onclientclick instead of onclick.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -