0

I have seen this question before, but none of the answers seems to work for me. This is my updatePanel section (inside hi.ascx):

<asp:UpdatePanel runat="server" ID="upUL" UpdateMode="Conditional" >
<ContentTemplate>

...

            <Angel:Pager id="pager" runat="server" OnPageClicked="Pager_PageSelected" />
        <!--End of control div-->
</ContentTemplate>
<Triggers>
    <asp:AsyncPostBackTrigger ControlID="lbBlock" />
    <asp:AsyncPostBackTrigger ControlID="lbUnblock" />
    <asp:AsyncPostBackTrigger ControlID="pager" EventName="PageClicked" />
</Triggers>
</asp:UpdatePanel>

Now this is the code within the Pager.ascx.vb:

Public Delegate Sub ClickPage(sender As Object, e As PageClickedEventArgs)
Public Event PageClicked As ClickPage

Public Class PageClickedEventArgs
    Inherits EventArgs
    Public Property PageNumber() As Integer
End Class

....

Protected Sub rpPaging_Click(ByVal sender As Object, ByVal e As CommandEventArgs)
    Dim pageNum As Integer
    Integer.TryParse(e.CommandArgument.ToString(), pageNum)
    If (pageNum <> 0) Then
        Dim args As New PageClickedEventArgs
        args.PageNumber = pageNum
        RaiseEvent PageClicked(sender, args)
    End If
    'SelectNewPage(pageNum)
End Sub

And finally, this is my code on the hi.ascx.vb page:

    Public Sub Pager_PageSelected(sender As Object, ByVal e As    Paging.PageClickedEventArgs)
        BindData(False, e.PageNumber)
    End Sub

As I stated in the title. When I raise an event from the pager.ascx, it causes a full post back(and works great but I wanted it to be in Ajax).
The other controls(LinkButtons) within this updatepanel like lbBlock and lbUnblock , are working great and not causing full postback!

Please please help me. I spent too much time on it and nothing seems to work!

thanks,
Ran

Ran
  • 155
  • 1
  • 10

2 Answers2

3

That solved the problem:

    Protected Sub rpPaging_onItemCreated(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)

    Dim lb = e.Item.FindControl("lbPage")
    If lb IsNot Nothing Then _
        ScriptManager.GetCurrent(Page).RegisterAsyncPostBackControl(lb)

End Sub

Apparently, Controls within a repeater would not register themselves automatically... So i needed to add each one of them to the scriptmanager!

Hope it would help to someone out there...

Ran
  • 155
  • 1
  • 10
0

asp.net would not know how to track your PageClicked event on the client side. So firing the conditional trigger would not happen.

If this event corresponds to the event of a button or linkbutton in your custom control, expose that event, and the update panel will use that to track the event on client side.

Not quite used to VB, this is how you expose an event in c#

public event EventHandler PageChanged
{
    add { grd.PageChanged += value; }
    remove { grd.PageChanged -= value; }
}
nunespascal
  • 17,584
  • 2
  • 43
  • 46
  • Thanks, first of, it is not matter if it is conditional or not. The event always causing a full postback. Sec, how do I "expose that event"? How do I make the updatepanel to track my PageCliked event? – Ran Jul 26 '12 at 06:53
  • Causes full postback even when it is not conditional, that is strange. Just should not happen. Can't figure what must be causing that. Not very used to vb, will post c# example. – nunespascal Jul 26 '12 at 07:07
  • C# is fine. what is grd? is it gridview? im using a repeater and i dont have pageChange event. And where to put ur code? should it be instead of mine: "Public Sub Pager_PageSelected" function? – Ran Jul 26 '12 at 07:14
  • I just used that as a example. You can expose any existing event in a child control that way. – nunespascal Jul 26 '12 at 07:24