469,889 Members | 1,244 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,889 developers. It's quick & easy.

Usercontrol with ajax update panel causes null reference exception.

If you expose a public property of a usercontrol that accesses an object on
the user control it will give a null reference exception when you wrap that
in an update panel.

Others are having the same problem. Here is a complete example:

Related to this: (But I am not doing dynamic user control creation)

Mar 14 '07 #1
2 8439
Hi Wayne,

I cannot seem to reproduce the issue you mentioned on asp.net forum. I've
created following simple WebUserControl and it's working fine on a WebForm:

<%@ Control Language="C#" ClassName="WebUserControl" %>

<script runat="server">

protected void Button1_Click(object sender, EventArgs e)
// Label1.Text = DateTime.Now.ToString();
LabelText = DateTime.Now.ToString();

public string LabelText
get { return Label1.Text; }
set { Label1.Text = value; }

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />
Please note that I'm not adding a ScriptManager onto the UserControl since
only one ScriptManager instance can exist on a WebForm; therefore the
ScriptManager will always be added to the WebForm.

I've also tried to use a MasterPage and still not able to reproduce it.

Would you please post a complete code listing that could reproduce the
issue? Thanks.
Walter Wang (wa****@online.microsoft.com, 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.

Mar 14 '07 #2
Hi Wayne,

Since a web page can contain only one ScriptManager control (either
directly on the page itself or indirectly inside a nested or parent
component), you can use ScriptManagerProxy
when you're using UpdatePanel on a content page or a web user control.
Walter Wang (wa****@online.microsoft.com, 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.

Mar 16 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Harry | last post: by
9 posts views Thread by davidr | last post: by
2 posts views Thread by DanWeaver | last post: by
17 posts views Thread by Arjen | last post: by
1 post views Thread by Mike P | last post: by
1 post views Thread by =?Utf-8?B?S3lsZSBNLiBCdXJucw==?= | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.