1

当通过procesSearchCriteria1 加载用户控件标题栏时,我希望PNL1 的默认按钮为SearchButton。当然,当它通过 ucBBB 加载时,我希望 SaveButton 成为 Pnl2 的默认按钮。这可能吗?

主页:

<asp:Panel runat="server" ID="Pnl1" defaultButton="">
    <uc1:AAA ID="procesSearchCriteria1" runat="server"/>
</asp:Panel>

<div class="separator"></div>

<asp:Panel runat="server" ID="Pnl2" defaultButton="">
    <uc2:BBBB ID="ucBBB" runat="server"/>
</asp:Panel>

用户控制过程搜索标准 1:

<uc3:TitleBar ID="ucTitleBarAAA" runat="server" Type="Search" />

用户控制 ucBBB:

<uc3:TitleBar ID="ucTitleBarBBB" runat="server" Type="Save" />

用户控件标题栏

 <asp:ImageButton ID="SearchButton" runat="server" ImageUrl="/Images/title_search.png" OnClick="SearchButton_Clicked" />
 <asp:ImageButton ID="SaveButton" runat="server" ImageUrl="/Images/title_save.png" OnClick="SaveButton_Clicked" />

我尝试将按钮的 ID 传递到如下所示的主页,但收到此错误消息:“PnlWerkprocesSearchCriteria1”的 DefaultButton 必须是 IButtonControl 类型的控件的 ID。而在浏览器中查看时,ID DefaultButton.UniqueID 确实等于按钮的 ID

主页背后的代码:

public procesSearchCriteria procesSearchCriteria { get { return procesSearchCriteria1; } }

protected void Page_Load(object sender, EventArgs e)
{
procesSearchCriteria.Load += new EventHandler(procesSearchCriteria_Load);
}

void procesSearchCriteria_Load(object sender, EventArgs e)
{
    ImageButton DefaultButton = procesSearchCriteria.DefaultButtonProcesSearchCriteria;
    Pnl1.DefaultButton = DefaultButton.UniqueID;
}

procesSearchCriteria1 背后的代码:

public ImageButton DefaultButtonProcesSearchCriteria { get; set; }
DefaultButtonProcesSearchCriteria = (ImageButton)ucTitleBarAAA.TitleBarSearchButton
4

0 回答 0