Get value from asp:textbox client side.
Posted on 2006-03-27
Ok, something i thought was easy has turned out not so much!
I am trying to get the value from an asp:textbox and without postback.
I have this.....
const string _AccountScript = @"
var chrAccountName = document.getElementById('txtAccount').value;
WinOpen('ToolsPopup.aspx?chrAccountName= + chrAccountName,290,520,'Aname');
ClientScript.RegisterClientScriptBlock(GetType(), "AddAccount", _AccountScript);
in button properties i have AddAccount();
I have debugged as best i can and the getElementById is where it falls over. I can set the var to a const string and it works fine??? My textbox is is without a doubt 'txtAccount' (correct case).
The error i get is 'Object Required'.
The second part....how can i stop the button posting back??