0
我有一个.NET 4的网页,其中包含一个用户控件有以下:
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
</asp:ScriptManagerProxy>
<asp:LinkButton ID="btnExpand" runat="server" Text="Expand..." ClientIDMode="AutoID"
OnClick="btnExpand_Click"></asp:LinkButton>
<asp:Label ID="btnDummy" runat="server"></asp:Label>
<asp:Panel ID="pnlMyPanel" runat="server">
<p>content</p>
</asp:Panel>
<ajaxToolkit:CollapsiblePanelExtender ID="cpeMyPanel" runat="server"
TargetControlID="pnlMyPanel" Collapsed="True" ExpandControlID="btnDummy"
CollapseControlID="btnDummy" BehaviorID="cpe">
</ajaxToolkit:CollapsiblePanelExtender>
当点击展开按钮,它执行以下代码:
protected void btnAddComment_Click(object sender, EventArgs e)
{
string script = "var cpeMyPanel = $find('" + cpeMyPanel.BehaviorID + "');\r\n" +
"if (cpeMyPanel != null)\r\n" +
" cpeMyPanel.expandPanel();\r\n" +
"else\r\n" +
" alert(cpeMyPanel is null');";
ScriptManager.RegisterStartupScript(Page, Page.GetType(),
"Expand", script, true);
}
当脚本在浏览器上运行时,我得到警报,但是$ find()总是返回null。最终目标是,当用户单击按钮时,我想在扩展面板之前在服务器上执行一些代码(例如准备一些内容)。
任何想法可能会失踪?有一个更好的方法吗?
由于提前,
丹