3

I work on a simple ASP Webform project (asp framework 4.0), and use VS 2010.

I have a some pages on my website where I want to use UpdatePanels.
On another page of my website, i need to use ModalPopupExtender control wich is included in the AjaxControlToolkit lib.

The problem that i encountered is that my UpdatePanels do not work at all if I include the AjaxControlToolkit library in my project (no need to implement any component of this library, just adding a reference to it in my project).
If I remove the reference to the lib, it works fine.


Do you have an idea on how to concile those both elements ? UpdatePanel and AjaxControlToolkit lib ?

Thanks a lot for your advice

Here is the simple UpdatePanel code I use:

<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand" OnItemDataBound="Repeater1_ItemDataBound">
    <ItemTemplate>
        <asp:LinkButton ID="lnk" runat="server" Text="show" CommandName="show"></asp:LinkButton>
    </ItemTemplate>
</asp:Repeater>


<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Label runat="server" ID="label1"></asp:Label>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Repeater1" EventName="ItemCommand" />
    </Triggers>
</asp:UpdatePanel>

In code behind, I use this :

protected void Page_Load(object sender, EventArgs e)
    {
        Repeater1.DataSource = new List<String>(){"zero", "un", "deux", "trois","quatre"};
        Repeater1.DataBind();
    }

    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        LinkButton lnk = ((LinkButton)e.Item.FindControl("lnk"));
        lnk.CommandArgument = e.Item.ItemIndex.ToString();
    }

    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "show")
            label1.Text = "You click" + e.CommandArgument;
    }
1
  • You are definitely getting some javascript errors in your browser. See if you can see any JS errors in your IE and paste them here.
    – Sev
    Dec 5, 2012 at 22:15

1 Answer 1

0

I found this post because i was the same problem when added a reference for AjaxToolKit.dll, then was looking what could be the problem then found this with the comment to see the javascript errors and was the solution :D

I had in my code a script to get the start of the refresh

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);

function BeginRequestHandler(sender, args) 
{
   var elementID = sender._activeElement.id;
   ...
}

was getting "TypeError: sender._activeElement is undefined" then changed the

var elementID = sender._activeElement.id;

to

var elementID = sender._postBackSettings.sourceElement.id;

and solved my problem.

Without the reference to the dll was working fine and when I remove it. With the reference I had to change the properties of the element.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.