Suppose I have several DevExpress controls, and one of them is a button. On this button, I want to add ClientInstanceNames for each of the other controls so that I can access them in a click event on the client side of the buttons.
WITH#:
String strID = "MyButton";
ASPxButton btn = new ASPxButton() { ClientInstanceName = strID , Text = "Click Here", Width = new Unit("100%"), AutoPostBack = false, CssFilePath = strCssFilePath, CssPostfix = strCssPostFix };
btn.ClientSideEvents.Click = "btnClick";
btn.JSProperties.Add("cp_MyTxtBx", strID );
I want to do something like this ...
JS:
<script type="text/javascript">
function btnClick(s, e) {
var theTxtBx = document.getElementById(s.cp_MyTxtBx);
theTxtBx.SetText('some text');
}
</script>
But that does not work. I know I can do it like this:
<script type="text/javascript">
function btnClick(s, e) {
MyTxtBx.SetText('some text');
}
</script>
But these controls are dynamically created, and I will not know their ClientInstanceNames until runtime.
So, how can I get a control based on the String JSProperty of my ClientInstanceName?
Thanks in advance.
Related posts, but not quite what I need:
How to access ASPxTextBox value from JavaScript
DevExpress: ?