Вопрос

I can't access ASPxComboBox component when it is in ASPxPageControl both tab pages. So I have this function added to ClientSideEvents with string.Format:

function(s, e) {{ 
    if (window['{1}']) {{ 
        {0}.SetSelectedItem(
            {0}.FindItemByText(
                {2}.GetText()
            )
        ); 
        {0}.Focus(); 
        {3}.PerformCallback(
            {0}.GetSelectedItem().value
        ); 
    }} 
}} 

And firing this function first at one tab page then at other page, I get error:

Microsoft JScript runtime error: Unable to get value of the property 'SetSelectedItem': object is null or undefined

Why is it that way? Could I somehow access that combobox after switching tabs?
Btw, ASPxPopupControl apears on both tabs then opened..

More context:

0 is ASPxClientControl.GetControlCollection().Get('<%=ASPxComboBox_Views.ClientID%>'), (compiles to ctl00_ctl00_ASPxSplitter_Main_ContentPlaceHolderMain_ContentProgramMain_ASPxRoundPanelMain_ASPxPageControl_Main_ASPxCallbackPanel_Redagavimas_ASPxCallbackPanel_RedagavimasGrid_GridLayout_Redagavimas_ASPxPopupControl_Layout_ASPxCallbackPanel_Views_ASPxComboBox_Views )
1 is ASPxClientControl.GetControlCollection().Get('<%=ASPxComboBox_Views.ClientInstanceName%>'), (compiles to cbViews )
2 is ASPxClientControl.GetControlCollection().Get('<%=GetClientStr(ASPxHyperLink_Desc.ClientID%>'), (compiles to ctl00_ctl00_ASPxSplitter_Main_ContentPlaceHolderMain_ContentProgramMain_ASPxRoundPanelMain_ASPxPageControl_Main_ASPxCallbackPanel_Redagavimas_ASPxCallbackPanel_RedagavimasGrid_GridLayout_Redagavimas_ASPxHyperLink_Desc )
3 is ASPxClientControl.GetControlCollection().Get('<%=ASPxCallbackPanel_Menu.ClientID%>'), (compiles to ctl00_ctl00_ASPxSplitter_Main_ContentPlaceHolderMain_ContentProgramMain_ASPxRoundPanelMain_ASPxPageControl_Main_ASPxCallbackPanel_Redagavimas_ASPxCallbackPanel_RedagavimasGrid_GridLayout_Redagavimas_ASPxPopupControl_Layout_ASPxCallbackPanel_Menu )

And it doesn't work if ASPxComboBox_Views is in ASPxPageControl tab. To be precise, my page looks like this:

<..>
<dx:ASPxPageControl ID="ASPxPageControl_Main">
    <TabPages>
        <dx:TabPage><..>
            <dx:ASPxGridView ID="ASPxGridView_Naudojimas">
            //From here starts partial page which is one for both tabpages
            <dx:ASPxPopupControl ID="ASPxPopupControl_Layout">
                <ContentCollection>
                    <dx:PopupControlContentControl ID="PopupControlContentControl_Layout">
                        <div><table><tr><td align="left" width="100%">
                            <dx:ASPxCallbackPanel ID="ASPxCallbackPanel_Views">
                                <PanelCollection>
                                    <dx:PanelContent ID="PanelContent1">
                                            <dx:ASPxComboBox ID="ASPxComboBox_Views" runat="server" ...>
        </dx:TabPage>
        <dx:TabPage><..>
            <dx:ASPxGridView ID="ASPxGridView_Redagavimas">
            //From here starts partial page which is one for both tabpages
            <dx:ASPxPopupControl ID="ASPxPopupControl_Layout">
                <ContentCollection>
                    <dx:PopupControlContentControl ID="PopupControlContentControl_Layout">
                        <div><table><tr><td align="left" width="100%">
                            <dx:ASPxCallbackPanel ID="ASPxCallbackPanel_Views">
                                <PanelCollection>
                                    <dx:PanelContent ID="PanelContent1">
                                            <dx:ASPxComboBox ID="ASPxComboBox_Views" runat="server" TextField="Description" ValueField="FullName" ClientInstanceName="cbViews" TextFormatString="{0}">
(deleted some properties just to be easier to read here)
Это было полезно?

Решение

You should set ClientInstanceName of all controls you use on client side.

<dx:ASPxCallbackPanel ClientInstanceName="cbPanel1" ...>
<dx:ASPxHyperLink ClientInstanceName="hyperlink1" ..../>

and then:

function(s, e) {{ 
    if (window.{0}) {{ 
        {0}.SetSelectedItem(
            {0}.FindItemByText(
                {1}.GetText()
            )
        ); 
        {0}.Focus(); 
        {2}.PerformCallback(
            {0}.GetSelectedItem().value
        ); 
    }} 
}} 

where:
0 - combo box ClientInstanceName
1 - hyperlink ClientInstanceName
2 - callbackpanel ClientInstanceName

And you should really visit links Niranjan posted.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top