Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / May 2006

Tip: Looking for answers? Try searching our database.

Losing Delegate On Postback

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris A. - 03 May 2006 19:01 GMT
I have authored a webcontrol that contains a SimpleCellCollection of
SimpleCell objects. Both have custom typeconverters that handle viewstate
de/serialization. When I click a SimpleCell in the browser, I get a postback
event but I never sink the ImageClickEventHandler delegate. I have seen posts
discussing attributes UniqueID.x and UniqueID.y being used in postbacks but
have no clue how to implement. Can you help? I am running ASP.NET 1.1.

Thanks,
MasterGaurav - 04 May 2006 13:11 GMT
EventHandler needs to be registered with the PostBack.

What interfaces are you implementing - IPostBackDataHandler /
IPostBackEventHandler / both?
How are you handling them?

--
Cheers,
Gaurav Vaish
http://mastergaurav.org
http://www.edujini.in
-------------------------------
To Hell with Murphy's Law.. When things go broke, FIX Them
-------------------------------
Chris A. - 16 May 2006 22:21 GMT
Sorry for the delay, I never got an email reply...

Here is what the control structure looks like:

Parent Webcontrol A
|___Collection of Type WebControl B
       |__WebControl B
            |__ImageButton (sink click event)

For Parent Webcontrol A : WebControl, INamingContainer
For Collection [Serializable()] : Collectionbase
For Webcontrol B : WebControl, IPostBackDataHandler, ICell, INamingContainer

I have a custom typeconverter for both the collection and Webcontrol B. The
typeconverter for the collection works fine but I lose which item (Webcontrol
B) was clicked. Also I can never debug break on SaveViewstate or
LoadViewstate for Webcontrol B.

> EventHandler needs to be registered with the PostBack.
>
[quoted text clipped - 10 lines]
> To Hell with Murphy's Law.. When things go broke, FIX Them
> -------------------------------
Gaurav Vaish (EduJini.IN) - 19 May 2006 19:20 GMT
> For Webcontrol B : WebControl, IPostBackDataHandler, ICell,
> INamingContainer

Looks something fishy in IPostBackDataHandler

And/Or the event that you have exposed
+
How you have added the handler.

May be u can post the content or mail me at
gaurav~DOT~vaish~AT~gmail~DOT~com

Signature

Happy Hacking,
Gaurav Vaish
http://www.mastergaurav.org
http://www.edujini.in
-------------------

Chris A. - 19 May 2006 21:49 GMT
In my custom collection I create a delegate for the CellInfoEventHandler when
each SimpleCell is added to the collection:

protected override void OnInsert(int index, object value)
        {
            SimpleCell cell = (SimpleCell) value;
            cell.OnClick += new CellInfoEventHandler(cell_OnClick);
            //base.OnInsert (index, value);
        }

I can debug and confirm that the SimpleCell exists and is added to the
collection but when I place a breakpoint on the SimpleCell overriden
SaveViewstate() and LoadViewstate() methods it never breaks into these
methods. Obviously the RegisterChildControls and RenderContents methods get
called as each SimpleCell is rendered on the design-time surface and in the
run-time aspx.

Note that I have a custom typeconverter for the SimpleCellCollection and the
SimpleCell. I have looked at the hidden Form values __EVENTTARGET and
__EVENTTARGET to view which SimpleCell has been clicked (essentially each is
an ImageButton). Any more ideas as to what is happening? Much thanks.

> > For Webcontrol B : WebControl, IPostBackDataHandler, ICell,
> > INamingContainer
[quoted text clipped - 7 lines]
> May be u can post the content or mail me at
> gaurav~DOT~vaish~AT~gmail~DOT~com
Gaurav Vaish (EduJini.IN) - 23 May 2006 18:42 GMT
Can you post / upload the complete code somewhere...

or may be mail us at consulting~AT~edujini~DOT~in
We should be able to provide some info....

Signature

Happy Hacking,
Gaurav Vaish
http://www.mastergaurav.org
http://www.edujini.in
-------------------

> In my custom collection I create a delegate for the CellInfoEventHandler
> when
[quoted text clipped - 34 lines]
>> May be u can post the content or mail me at
>> gaurav~DOT~vaish~AT~gmail~DOT~com
Chris A. - 23 May 2006 20:23 GMT
Gaurav,

Thanks for your reply but is your assistance contingent upon a consulting
fee? I note that you are now using consulting@edujini.in versus
gaurav.vaish@gmail.com. Please let me know before I forward you the project.

> Can you post / upload the complete code somewhere...
>
[quoted text clipped - 39 lines]
> >> May be u can post the content or mail me at
> >> gaurav~DOT~vaish~AT~gmail~DOT~com
Gaurav Vaish (EduJini.IN) - 25 May 2006 06:30 GMT
> Thanks for your reply but is your assistance contingent upon a consulting
> fee? I note that you are now using consulting@edujini.in versus
> gaurav.vaish@gmail.com. Please let me know before I forward you the
> project.

No. No fee, at least for the first query / solution. :-)

If you forward it to consulting~AT~..., there may be more people than just
me to work on it. :)
If you forward is to gaurav~DOT~..., I'll manually forward it to
consulting~AT~...

A request... please do not write our complete email address. They get
abused.

Signature

Happy Hacking,
Gaurav Vaish
http://www.mastergaurav.org
http://www.edujini.in
-------------------


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.