【问题标题】:I can't access ASPxComboBox component when it is in both ASPxPageControl tab pages当它位于两个 ASPxPageControl 选项卡页中时,我无法访问 ASPxComboBox 组件
【发布时间】:2012-06-20 08:19:12
【问题描述】:

当它在 ASPxPageControl 两个标签页中时,我无法访问 ASPxComboBox 组件。 所以我用 string.Format 将此函数添加到 ClientSideEvents:

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

首先在一个标签页然后在另一页触发此功能,我得到错误:

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

为什么会这样?我可以在切换标签后以某种方式访问​​该组合框吗?
顺便说一句,ASPxPopupControl 出现在两个选项卡上然后打开..

更多上下文:

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 )

如果 ASPxComboBox_Views 位于 ASPxPageControl 选项卡中,则它不起作用。 准确地说,我的页面是这样的:

<..>
<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)

【问题讨论】:

标签: javascript asp.net devexpress aspxcombobox


【解决方案1】:

您应该设置您在客户端使用的所有控件的 ClientInstanceName。

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

然后:

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

地点:
0 - 组合框 ClientInstanceName
1 - 超链接 ClientInstanceName
2 - 回调面板 ClientInstanceName

您真的应该访问 Niranjan 发布的链接。

【讨论】:

  • 非常感谢!问题是因为 ASPxClientControl.GetControlCollection().Get(..) 的使用,而不仅仅是 .ClientInstanceName。
  • @Bomberlt 真正的问题是 DX 控件的“令人敬畏”的工作方式。这是火车残骸。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-28
  • 2012-08-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-29
相关资源
最近更新 更多