How would I extract the value of an aspxTextBox using javascript? Also, why is SO MUCH html generated, especially tables, for a simple textbox?
Get the value of an aspxTextBox with Javascript
Answers approved by DevExpress Support
Hi Matt,
Please use the ASPxTextBox.GetValue client-side method for this purpose. Here is some sample code:
<script language=javascript>
function getEditValue(){
var value = ASPxTextBox1.GetValue();
if(value)
alert(value);
}
</script>
Please try this solution and let us know your results.
As for your comments, this is how our ASPx editors are designed: all our editors are generated as HTML tables.
Thanks,
Vito
I'm getting an undefined error. Here is my code:
<script type="text/javascript">
function clg_Find(category, text)
{
// Has any search text been provided?
if (document.getElementById(text).GetValue == '')
{
alert('Please provide some text to search on.');
document.getElementById(text).focus();
return false;
}
var value = document.getElementById(text).GetValue;
alert(document.getElementById(text)); ** This gives an [object] message **
alert(value); ** This gives the undefined message **
// Code to build the url goes here
// Redirect the user
location.href = url;
}
</script>
The parameters are as follows:
category is the ClientID of a AspxComboBox
text is the ClientID of a AspxTextBox
Any help would be appreciated! Thanks!
Hi Matt,
It is not quite correct to use the document.getElementById method in this situation. Please use the aspxGetControlCollection().Get() method for this purpose. Here is a modified sample code:
<script language=javascript>
function getEditValue(editorID){
var editor = aspxGetControlCollection().Get(editorID);
if(editor){
var value = editor.GetValue();
if(value)
alert(value);
}
}
</script>
Thanks,
Vito