Problem with asp:UpdatePanel inside a Web User Control

M

musosdev

Hi guys

I've created a nice little Comments UI engine. Comments can be added, and
are automatically added to the list of comments below, in a nice AJAX way,
using Update Panels and the like.

I'm trying to encapsulate this functionality in a web user control. I've got
the control working, sort of, but the variables I need (the item we're
commenting on, etc), get deleted on the AJAX postback. Can anyone shed some
light on how to fix this...?

Here's the lines from the aspx...

<%@ Register src="../../_ctrl/Comments.ascx" tagname="Comments"
tagprefix="uc1" %>
....
<uc1:Comments ID="comComments" runat="server" />

And the C# that passes the variables...

// comments
comComments.ItemType = CommentTypes.Project;
comComments.ItemID = pid;

These variables are declared as public string. I tried static, but then I
need to use an instance of my WebUserControl class. I'm not sure that's right?

Anyway, the first time the page runs, the ItemType and ItemID are passed
fine, and then a partial postback (of the UpdatePanel) occurs, both of these
items are null.

How can I persist them through the postback?

Thanks



Dan
 
M

musosdev

Hi again

Just wanted to say I've sorted it. I created some public variables with
get/set..

public string var { get {} set {} }

and then create private variables which were able to be static.

Of course, if anyone knows of a better way, I'd love to hear!

Cheers


Dan
 

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

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top