Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problem with asp:UpdatePanel inside a Web User Control

Reply
Thread Tools

Problem with asp:UpdatePanel inside a Web User Control

 
 
musosdev
Guest
Posts: n/a
 
      09-28-2009
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
 
Reply With Quote
 
 
 
 
musosdev
Guest
Posts: n/a
 
      09-28-2009
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing USER CONTROL which is inside Masterpagethrough Another USER Control inside normal page. Kiran More ASP .Net Web Controls 2 11-14-2006 12:58 PM
Custom User Control is not rendered inside another user control in a server table. Leeor Chernov ASP .Net 2 10-16-2005 08:35 AM
Web User Control with GridView can derive new Web User Control? ABC ASP .Net 1 10-04-2005 12:29 PM
Web User Control with GridView can derive new Web User Control? ABC ASP .Net 0 10-03-2005 10:23 AM
Event not firing for user control inside user control vatech1993 ASP .Net 4 12-11-2004 02:51 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57