Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

custom propertytype, wont fire clickevent before page created

Vote:
 

Hi!

First time here.. so please correct me if Im doing something wrong :)

My propblem is that Im having this custom propertytype that I have built, the property has a  normal asp:button with a click-event bound to it (a serverside click-event).

This button adds an item into a list.. but I wont go into the details regarding that since thats not the problem.

The problem is that if I create a new page with the pagetype that contains the custom propertytype, and then try to press the asp:button, the click-event wont fire.. but If I save my page and then press/click the asp:button, the event fires.

Any thoughts or ideas?

 

Thanks in advance!

#61935
Oct 08, 2012 10:11
Vote:
 

Maybe the validation for PageName kicks in? Or are you getting a postback?

#61939
Oct 08, 2012 11:35
Vote:
 

Yes I do get a postback, but for some reason it wont step into the click-function.. and the same goes if I enter a name for my page and fills in all the other properties and press the button.

#61940
Oct 08, 2012 12:32
Vote:
 

OK. Are you adding the button from CreateEditControls()?

People can help better if you post the code.

#61944
Oct 08, 2012 13:04
Vote:
 

No, its added directly in the user-control only.

And my bad.. its not an asp:button.. ist an EPiServerUI:ToolButton..

Well the code is:

<asp:UpdatePanel ID="upPanel" runat="server" UpdateMode="Always">
        <ContentTemplate>
            <asp:MultiView runat="server" ID="mvList">
                    <asp:View runat="server">
                <table>
                    <tr>
                        <th><b>Key</b></th>
                        <th><b>Value</b></th>
                        <th></th>
                    </tr>
                    <asp:Repeater runat="server" ID="rpKeysAndValues" OnItemCommand="rpKeysAndValues_OnCommand" OnItemDataBound="rpkeysAndValues_OnDataBound">
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <asp:TextBox runat="server" Text='<%# Eval("Key")%>' AutoPostBack="True" ID="tbEditKey" OnTextChanged="tbEditKey_OnTextChanged"></asp:TextBox></td>
                                <td>
                                    <asp:TextBox runat="server" Text='<%# Eval("Value")%>' AutoPostBack="True" ID="tbEditValue" OnTextChanged="tbEditValue_OnTextChanged"></asp:TextBox></td>
                                <td>
                                    <EPiServerUI:ToolButton SkinID="Delete" runat="server" CommandName="delete" Text="Delete" ID="btnDelete" CommandArgument='<%# Eval("Key") %>'></EPiServerUI:ToolButton>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </table>
                        </asp:View>
                <asp:View runat="server">
                    <b>No items added!</b>
                </asp:View>
            </asp:MultiView>
            <br />
            <br />
            <asp:Panel runat="server" ID='pAdd'>
                <table>
                    <tr>
                        <td>Key: </td>
                        <td>
                            <asp:TextBox runat="server" ID="tbKey"></asp:TextBox></td>
                        <td>   </td>
                        <td>Value: </td>
                        <td>
                            <asp:TextBox runat="server" ID="tbValue"></asp:TextBox></td>
                        <td colspan="2">
                            <EPiServerUI:ToolButton ID="BtnAdd" runat="server" SkinID="Add" Text="Add" OnClick="BtnAddClick" />
                        </td>
                    </tr>
                </table>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>

    and the only code on the server-side that relates to the button is this:

protected void BtnAddClick(object sender, EventArgs e)
        {
            _list.Add(tbKey.Text,tbValue.Text);
            SaveListToViewState();
            SaveChanges();
            PopulateRepeater();
        }

    Thanks!

#61946
Oct 08, 2012 13:12
Vote:
 

We also need the code that inherits PropertyString or other propertytype... If you haven't already take a look at Joel's post on custom properties:

http://joelabrahamsson.com/entry/how-to-create-a-custom-episerver-property

#61947
Oct 08, 2012 13:30
Vote:
 
#61948
Oct 08, 2012 13:42
Vote:
 
    [PageDefinitionTypePlugIn(
    DisplayName = "Dictionary",
    Description = "Used to create a list with objects containing a key and a value")]
    [UserControlProperty(
    EditUserControlPath = "/Templates/Web/Controls/CustomProperties/Dictionary/DictionaryControl.ascx")]
    public class PropertyDictionary : UserControlPropertyBase<string>
    {
       
    }

    This is all the code I got.

#61949
Edited, Oct 08, 2012 13:46
Vote:
 

You could try attaching the events from code behind and see if that helps.

Also try removing the ASP.NET AJAX stuff (UpdatePanel) and see what happends then - I don't trust that functionality at all.

The UserControlPropertyBase is something from ETF right? You could ask those guys for support as well.

I would personally have chosen to add controls from codebehind and not use a user control.

#62000
Oct 09, 2012 17:25
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.