Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In code-behind, I am able to find out if ddlCategory is clicked which is inside ContentTemplate; however, I also need to find out if buttonAddProduct or bttonSaveProduct is clicked ,which are outside of ContentTemplate. Please help.
Thanks!
XML
<asp:Button ID="buttonAddProduct" Text="Add" runat="server" />
<asp:Button ID="buttonSaveProduct" Text="Save" runat="server" />

<!-- Add Client-Side Validation ASP.NET Validators -->
<asp:UpdatePanel ID="upDetail" ChildrenAsTriggers="True" runat="server">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="buttonAddProduct" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="buttonSaveProduct" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="ddlCategory" EventName="SelectedIndexChanged" />
    </Triggers>

    <ContentTemplate>
        <table class="layoutTable">
            <tr>
                <td width="100%" style="vertical-align: top">
                    <label for="ddlProductAttributes" accesskey="c">
                        Attribute Names:
                    </label>
                    <telerik:RadComboBox ID="ddlCategory" AutoPostBack="true" Width="50%" runat="server">
                    </telerik:RadComboBox>
                </td>
            </tr>
        </table>
    </ContentTemplate>
</asp:UpdatePanel>
Posted
Comments
Kornfeld Eliyahu Peter 20-Nov-14 12:37pm    
Attach event handler to the buttons!
samkernel 20-Nov-14 13:44pm    
Thanks for response ! Just like to clarify: I already have event handler in code behind as follows, which is working fine as expected.

Additionally, I want to know in my custom validation method which particular button is clicked. Based on button type, I want to apply different business rule.

Private Sub BtnSave_Click(sender As Object, e As System.EventArgs) Handles btnSave.Click
RaiseEvent SaveProduct(sender, e)
End Sub
samkernel 20-Nov-14 13:52pm    
As you suggested when I added the event handler to the button (buttonSaveProduct) as below:
<asp:Button ID="buttonSaveProduct" OnClick="BtnSave_Click" Text="Save" runat="server" />, the following compilation error was thrown.

Compiler Error Message: BC30456: 'buttonSaveProduct' is not a member of 'ASP.pages_Products_ProductDetails_aspx'.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900