user1706522
user1706522

Reputation: 11

Set the defaultbutton of a panel depending on action in usercontrol, asp.net

When the usercontrol Titlebar is loaded through procesSearchCriteria1 I want the defaultbutton of PNL1 to be SearchButton. Of course when it's loaded through ucBBB I want the SaveButton to be the defaultButton of Pnl2. Is this possible?

Mainpage:

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

UserControl procesSearchCriteria1:

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

UserControl ucBBB:

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

UserControl Titlebar

 <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" />

I've tried to pass the Id of the button to main page like below but get this errormessage: The DefaultButton of 'PnlWerkprocesSearchCriteria1' must be the ID of a control of type IButtonControl. while the id DefaultButton.UniqueID does equal the Id of the button when looked in the browser

Code Behind Mainpage:

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;
}

Code behind procesSearchCriteria1:

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

Upvotes: 1

Views: 823

Answers (0)

Related Questions