AJAX n00b - custom server control in an UpdatePanel causes full postback



[apologies if this is the wrong newsgroup, couldn't find one for atlas/ajax]

Hi all,

I have a custom server control (inherits from control) that is, essentially,
a DIV containing a table with several rows, each of which has a DIV in it.
It is basically a menu of items. When the user clicks on an item div, the
event bubbles up to the table, the table calls __doPostBack and on the
server side the item is added to another DIV (let's call it
divSelectedItems). Works like a charm, but now I'd like to use an ASP.Net
AJAX UpdatePanel to do the updating of divSelectedItems when items are
selected. I put both my server control (the menu) and my divSelectedItems in
an updatepanel, but clicking on the items still causes a full postback. For
kicks, I put a button control in the update panel and add some text to the
divSelectedItems when the button is clicked. The button works with the
UpdatePanel (ie, does not cause a full postback) but my server control does
not. How can I get the UpdatePanel to convince my server control to use it's
AJAX magic rather than doing a full postback?? TIA!





Brief update:

I tried explicitly adding my control as a trigger (I thought this was
unecessary for controls that were IN the updatepanel, but apparently not?).
It added it like so:

Dim o As New Web.UI.AsyncPostBackTrigger()
o.ControlID = lobItems.UniqueID
o.EventName = "Click"

Now it works for the FIRST CLICK only, after that it's back to a full
postback again. Any help? Thanks...

Walter Wang [MSFT]

Hi Monty,

Without complete code of your menu-like control, it's hard to say which
part went wrong. However, we do have some guidelines on how to write an
ASP.NET AJAX-aware control:

#ASP.NET Forums - HOWTO: Write controls compatible with UpdatePanel without
linking to the ASP.NET AJAX DLL

Please refer to above document and modify your control accordingly, and
feel free to let me know if you have any questions.

Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

Get notification to my posts through email? Please refer to
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at

This posting is provided "AS IS" with no warranties, and confers no rights.


That is a cool article, and I implemented it in my server control, but it
did not affect the main issue I am experiencing:

The first click on my "trigger" control does an async postback perfectly -
great! The second click on it causes a full postback. Repeat ad nauseum. Any
ideas? Thanks.

Walter Wang [MSFT]

Hi Monty,

If done correctly, the control should have no idea of AJAX but still could
update without full page postback if placed inside a UpdatePanel. Would you
please post some code or send me a reproducible web project so that I can
help find the root cause? Thanks.

Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

This posting is provided "AS IS" with no warranties, and confers no rights.



baradi hakim


I have the same problem, didi anyone resolve it ?

this is my code :

public class RightTable : Control, INamingContainer
protected override void CreateChildControls()
this.iNbColomns = this.ColomnHeaders.Length;
this.iNbRows = this.RowHeaders.Length;

if (this.iNbColomns > 0 && this.iNbRows > 0)
tblConteneur = new Table();
//tblConteneur.BorderWidth = Unit.Pixel(1);
TableCell td1;
TableRow tr1 = new TableRow();
for (int i = 0; i < this.iNbColomns + 1; i++)
td1 = new TableCell();

TableRow tr2 = new TableRow();
tr2.CssClass = this.HeaderStyle;

TableCell td2 = new TableCell();
td2.Text = (this.HeaderStyle != null && this.HeaderStyle
!= "" ? "<font class=\"" + this.HeaderStyle + "\">" : "") + this.Heading
+ (this.HeaderStyle != null && this.HeaderStyle != "" ? "</font>" : "")

//first line with colomn headers
for (int i = 0; i < this.iNbColomns; i++)
td2 = new TableCell();
td2.BorderWidth = Unit.Pixel(1);
LinkButton lbColumnHeader = new LinkButton();
Header oColomnHeder = this.ColomnHeaders;
lbColumnHeader.Text = (this.HeaderStyle != null &&
this.HeaderStyle != "" ? "<font class=\"" + this.HeaderStyle + "\">" :
"") + oColomnHeder.Name + (this.HeaderStyle != null && this.HeaderStyle
!= "" ? "</font>" : "");
lbColumnHeader.CommandArgument =
lbColumnHeader.Click += new

bool bStyleAlernate = true;
for (int j = 0; j < this.iNbRows; j++)
TableRow trx = new TableRow();
if (bStyleAlernate)
trx.CssClass = this.RowStyle;
trx.CssClass = this.AlternatingRowStyle;

bStyleAlernate = !bStyleAlernate;

TableCell tdx = new TableCell();
tdx.BorderWidth = Unit.Pixel(1);
tdx.CssClass = this.HeaderStyle;
LinkButton lbRowHeader = new LinkButton();
RowHeader oRowHeader = this.RowHeaders[j];
lbRowHeader.Text = (this.HeaderStyle != null &&
this.HeaderStyle != "" ? "<font class=\"" + this.HeaderStyle + "\">" :
"") + oRowHeader.Name + (this.HeaderStyle != null && this.HeaderStyle !=
"" ? "</font>" : "");
lbRowHeader.CommandArgument =
oRowHeader.Id.ToString() + "," + ((int)oRowHeader.RowType).ToString();
lbRowHeader.Click += new

for (int i = 0; i < this.iNbColomns; i++)
tdx = new TableCell();
tdx.BorderWidth = Unit.Pixel(1);
if (this.Values[j] != null)
TableCase TC = this.Values[j];
RightCheckBox T2dCb = new
RightCheckBox(TC.RowId, TC.ColomnId, oRowHeader.RowType);
T2dCb.Checked = TC.Value;
T2dCb.AutoPostBack = true;
T2dCb.CheckedChanged += new



this.EnabledDisabledControl(this.Controls, "", true);

In my case the CheckBox enable UpdatePanel, but not the LinkButon

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question