views:

46

answers:

1

Hi.

ASP.NET 3.5 SP 1 / Visual Studio 2008 V 9.x RTM

I am trying to get a button inside a repeater inside an updatepanel to fire. I't won't. I have tried adding a trigger outside the ContentTemplate and inside the UpdatePanel to no avail:

 <Triggers>  
        <asp:AsyncPostBackTrigger ControlID="BtnAddStatus" EventName="Click" />  
    </Triggers> 

In fact, the AsyncPostBackTrigger's ControlID is always red and tells me "Cannot Resolve Symbol". This seems to be the case no matter where on the page I put the trigger.

I have read posts that have solved this problem by putting the button outside of the UpdatePanel but then, graphically speaking, the button will not be in the correct spot. It needs to be DIV with the ID of btnDiv.

So... how do I get the below button to fire?

<asp:Button ID="BtnAddStatus" CssClass="small button Detail" Text="Share" runat="server" />

ASPX code as follows:

<asp:Content ContentPlaceHolderID="ContentCenter" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1"  UpdateMode="Always" runat="server">
        <ContentTemplate>
            <asp:Label ID="lblMessage" runat="server"></asp:Label>
            <asp:Repeater ID="repFilter" runat="server" 
                onitemcommand="RepFilterItemCommand">
                <HeaderTemplate>
                    <div class="UIComposer_Box">
                        <span class="w">
                            <asp:TextBox class="input" ID="txtStatusUpdate" TextMode="MultiLine" Columns="60"
                                name="txtStatusUpdate" Style="overflow: hidden; height: 40px; color: rgb(51, 51, 51);"
                                runat="server"></asp:TextBox>
                        </span>
                        <br clear="all">
                        <div id="btnDiv" style="padding: 10px 5px; height: 30px;" align="left">
                            <span style="float: left;">&nbsp;PHP, Codeigniter, JQuery, AJAX Programming + 
                            Tutorials ( <a href="http://www.x.info" target="_blank" style="color: rgb(236, 9, 43);">
                                    www.x.info</a> )&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; </span>
                            <asp:Button ID="BtnAddStatus" CssClass="small button Detail" Text="Share" runat="server" />
                        </div>
                    </div>
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" Text='<%# ((Alert)Container.DataItem).Message  %>' runat="server"></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    <br class="clear" />
                </FooterTemplate>
            </asp:Repeater>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

AND MY PAGE LOAD CODE:

protected void Page_Load(object sender, EventArgs e)
        {
            _presenter = new DefaultPresenter();
            _presenter.Init(this);
        }

AND THE BtnStatusClick Method:

protected void BtnAddStatusClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                var su = new StatusUpdate
                             {
                                 CreateDate = DateTime.Now,
                                 AccountId = _userSession.CurrentUser.AccountId,
                                 Status = "" //txtStatusUpdate.Text
                             };

                _statusRepository.SaveStatusUpdate(su);
                _alertService.AddStatusUpdateAlert(su);

                _presenter = new DefaultPresenter();
                _presenter.Init(this);


            }

        }

Thanks again.

A: 

Have you tried setting the click event in the button instead of handling it from the code behind?

<asp:Button OnClick="BtnAddStatusClick" ID="BtnAddStatus" CssClass="small button Detail" Text="Share" runat="server" />
rockinthesixstring
Thanks for the response... I should have added the OnClick event to my original post... thanks for noticing. I have tried it both ways - handling from the code behind and setting the click event... in both cases nothing happens.
Code Sherpa