Question

I'm writing a small noticeboard app and most of it seems to work so far. However I've tried to add an Ajax panel to the notice viewing page, and cannot get it to work.

The site uses a master page with three content regions defined, which in the case of this page are used for a notice filter, a list of notice titles (a datalist that's populated in the Page.Load event), and the currently displayed notice. When you click a title it should load the notice.

The problem is that I want the currently displayed notice to be on a Ajax panel, but the trigger is in a different content region. I have put a script manager outside the content placeholders on the master page, and on the aspx page I've put an update panel around the content inside the notice view region with the following trigger:

<Triggers>
    <asp:AsyncPostBackTrigger ControlID="dlSelector" EventName="ItemCommand" />
</Triggers>

And in the Page.Load event I have:

'Get the script manager first, and register the selector as a postback
Dim sm1 As ScriptManager = ScriptManager.GetCurrent(Page)
sm1.RegisterAsyncPostBackControl(dlSelector)

This compiles and the code portion seems to run OK, but I get the error 'A control with ID 'dlSelector' could not be found for the trigger in UpdatePanel 'UpdatePanel1'.' If I replace

sm1.RegisterAsyncPostBackControl(dlSelector)

with

sm1.RegisterAsyncPostBackControl(Page.FindControl("dlSelector"))

then I get an error that FindControl has returned null and again it falls over. What am I doing wrong?

Was it helpful?

Solution

The Master page means that your control names will have been mangled
(e.g. ct100_someotherstuff_nameOfControl), that is why FindControl is coming back empty handed. You need to register the post back control using the proper id of the control.

Read this from Rick Strahl it was referenced in this post.

Hope it helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top