How to access the DevExpress ASPx control through JSProperties on the client

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: ?

+3
2

, , :

var theTxtBx = window[s.cp_MyTxtBx];

devex ClientInstanceName .

+5

- ...

, , .

javascript, , .

var ServerSideList = new List<string>();

while(CreatingTextBoxes)
{
    ...
    ServerSideList.Add(uniqueTextboxName);
}
....


var sb = new System.Text.StringBuilder();

sb.AppendLine("var clientSideList = [];");

foreach(var s in ServerSideList)
{
        sb.Append("clientSideList.push(");
        sb.Append(s);
        sb.AppendLine(");");
}

AspLiteralObject.Text = sb.ToString();

clientSideList.

<script type="text/javascript">
    function btnClick(s, e) {
        var i;
        var theTxtBx;

        for(i = 0; i < clientSideList.length; i++)
        {
            theTxtBx = clientSideList[i];
            theTxtBx.SetText('some text');
        }
    }
</script>
-1

All Articles