1
votes

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.

1
Hmm... no other responses to this? Anything else I can add or clarify? - Peter
Its the "View" - basically the method that wires up the front - end display. The meat of it shows status updates as such: _view.ShowAlerts(_alertService.GetAlertsByAccountId(_userSession.CurrentUser.AccountId)); I don't think my problem has anything to do with this but I am willing to explore anything at this point... - Peter

1 Answers

0
votes

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