当 ASPxComboBox 组件在 ASPxPageControl 两个标签页中时,我无法访问它。 所以我用 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)
最佳答案
您应该为您在客户端使用的所有控件设置 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 发布的链接。
关于javascript - 当 ASPxComboBox 组件在两个 ASPxPageControl 标签页中时,我无法访问它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11115457/