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
"musosdev" wrote:
> 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
|