views:

408

answers:

3

Hi Everyone,

Is it possible to add an event to a control which is inside another control, like say a PlaceHolder control using the designer?

When the control is alone on the form this works perfectly... you simply add it from the properties window by clicking the thunder icon and clicking on the event needed.

I know I can do by adding it manually but it would just be faster if it were generated for me. To test this, add the following to a form and try adding the OnClick event of the btnTest through the designer or properties window:

<asp:PlaceHolder ID="phTest" runat="server">
    <asp:Button runat="server" Text="Button" ID="btnTest" />
</asp:PlaceHolder>

Any help is appreciated

Regards

A: 
    <asp:PlaceHolder ID="phTest" runat="server">
    <asp:Button runat="server" Text="Button" ID="btnTest" OnClick="bUpdate_Click" />
</asp:PlaceHolder>

I have had to do it manually in my project and as long as you match up the eventargs it was straight forward

Howlingfish
A: 

I don't think PlaceHolder control is using for this purpose. From MSDN

The PlaceHolder Web server control enables you to place an empty container control within the page and then dynamically add, remove, or loop through child elements at run time. The control only renders its child elements; it has no HTML-based output of its own.

Anuraj
Yes you are right about this. The problem is when using say a Panel it generates a <div> tag which i do not want. Seems you can specify how to render a control in vs 2010 i.e. whether or not to show specific html tags or not
Pechar
A: 

Well I guess there is NO way it can be done through the designer, except by adding the eventhandler to the button before you put it into the Placeholder. Thanks for the help guys...

Pechar