CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.web_parts_and_personalization Tags:
Item Type: NewsGroup Date Entered: 3/23/2006 6:24:07 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 3 Views: 28 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
4 Items, 1 Pages 1 |< << Go >> >|
Sonofthesun
Asp.Net User
Problem with connections timing in event sequence after post back3/23/2006 6:24:07 AM

0/0

Hi,

I have problem concerning the connecting provider and consumer after page events are raised. Let's start with little bit background information and head step-by-step to actual problem.

I'm developing enterprise level solution using the web part architecture. Portal framework provides us highly flexible platform to customize the layouts (master pages, web parts etc.) and functionalities based on roles, licenses etc. Dynamic loading of the WebParts is adaptation of the Mike Harder's PDC05 samples (loading web parts based on settings in database with customized WebPartManager in OnInit stage - Excellent example by the way).

The problem which I ran into is the event sequence and the connection creation between web parts. We have separate business logic layer, which unfortunately can not be used (at least now) with the objectDataSource, so the approach is that the provider web part provides the necessary information for the consumer and the consumer renders the necessary functionality based on that.

So. I have one list web part (with composite control, rendering in gridview) and one details web part (with composite control, rendering in detailsview).

  • List web part provides the collection of entities and the selected index for the details web part
  • Details web part renders the content to details view

If we change the details view mode to edit by f.ex. using the standard edit command field, the edit event is raised before the connection is created. There for we get error, since the necessary data required for the functionality is not available. I was planning to bind the collection to consumer side web part in the CreateChildConrols method, so that the necessary information would exist for the even handling.

Any thoughts? So the question is:

Is there a way to make sure that the connection creation happens before the events are raised?

This is not an issue, if we use user controls for rendering the data and handle the events on normal page, as we can see from the Basic Instinct Article: http://msdn.microsoft.com/msdnmag/issues/06/02/BasicInstincts/. In our case however the web parts are in seperate assembly and inherited from the webpart class.

Basically the web part connections are created (checked using the Reflector - Magnificent tool) after the Page LoadComplete event. WebPartManagers creates the dynamic connections from the StaticConnection collection (and from few other places). Can I by pass the problem using ConnectWebParts method of the WebPartManager (I'm testing this nevertheless today) for connecting the necessary web parts? Currently I'm connecting them using the StaticConnections collection.

Thanks for any comments.

- Vsku

 


Vesa Juvonen
Sonofthesun
Asp.Net User
Re: Problem with connections timing in event sequence after post back3/23/2006 11:21:55 AM

0/0

Hi,

let's refrase the question. Following code is modification of the PDC05 demos (external web parts, employeeconsumerWebPart).

[ConnectionConsumer("Employee")]
public void SetEmployee(IWebPartRow employeeProvider) {
_employeeProvider = employeeProvider;
}

protected override void CreateChildControls()
{
Button btn = new Button();
btn.Text =
"Action: ";
btn.Click +=
delegate {BtnClick(btn);};
Controls.Add(btn);
base.CreateChildControls();
}

private void BtnClick(object doc)
{
//Do something based on data from provider...
//or go to database based on some selection etc.
}

As you can see from the code, I added new button to web part and created handler for the button click event. Now when I click the button, the btnClick handler is called before the provider is set.

Is there a way to connect the provider before the btnClick handler is called?

Thanks for the comments advance.

- Vsku


Vesa Juvonen
mharder
Asp.Net User
Re: Problem with connections timing in event sequence after post back3/23/2006 7:43:14 PM

0/0

If some action requires data that isn't available until after connections are executed, the recommended design is to use a member variable to remember that the action occurred, then actually process the action *after* connections have been executed.  To modify the above example:

private bool _buttonClicked = false;
private void BtnClick(object doc) {
    _buttonClicked = true;
}
protected override void OnPreRender(EventArgs e) {
    // Get data from connection provider
    if (_buttonClicked) {
       // Process button click using data from connection provider
    }
}


-Mike
http://blogs.msdn.com/mharder

This posting is provided "AS IS" with no warranties, and confers no rights.
Sonofthesun
Asp.Net User
Re: Problem with connections timing in event sequence after post back3/24/2006 7:14:20 AM

0/0

Yes of course... how stuped of me...
Thanks for the clarification.

- Vsku


Vesa Juvonen
4 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Computer Security--ESORICS 2002: 7th European Symposium on Research in Computer Security, Zurich, Switzerland, October 14-16, 2002 : Proceedings Authors: Dieter Gollmann, Günter Karjoth, Michael Waidner, Pages: 279, Published: 2002
Jonathan Edwards and the Metaphysics of Sin Authors: Oliver Crisp, Pages: 146, Published: 2005
Build Your Own Framework with Visual FoxPro Authors: Ken Chazotte, Pages: 330, Published: 2004
Pain Management: A Practical Guide for Clinicians Authors: Richard S. Weiner, Pages: 1138, Published: 2002
Philosophies of History: From Enlightenment to Post-modernity Authors: Robert Burns, Hugh Rayment-Pickard, Pages: 360, Published: 2000
Sweden's Capital Imports and Exports Authors: Jucker-Fleetwood, Erin Elver Jucker-Fleetwood, Pages: 223, Published: 1977

Web:
Page Event Sequence The page event sequence is crucial to understanding how the WebControl ... when the page is returned and it allows tracking of values that don't POST back. ...
Timing and Synchronization in JavaScript - Opera Developer Community Feb 27, 2007 ... For a bubbling event, the sequence is like this: .... in the case of a slow connection, might render the page one piece at a time. ...
Summary of Problems with Posttribulationism (by Ron Rhodes) Disagreement as to a Specific Order of Events at the Time of the Second Coming. Posttribulationists rarely offer a specific sequence of events in connection ...
Web Forms Page Processing It is important to understand the sequence of events that occurs when a Web Forms .... NET page framework restores the control properties and postback data. ...
Web Forms Page Processing It is important to understand the sequence of events that occurs when a Web Forms .... NET page framework restores the control properties and postback data. ...
Windows BBS - windows2000 Problems after SP4 & Rollup installation Back to safe mode and the event logs. You will hopefully have some juicy errors .... I did post this problem previously on an MS Windows Update Newsgroup ...
Sequence of events/signals that occur on PC side on PSD dial-up ... what are the sequence of events that occur on PC side. .... some at the same time as CONNECT, and some well after the CONNECT message. ...
AJAX Rich User Interfaces - by Jep Castelein: AJAX Latency ... Sep 4, 2005 ... Clearly specify the sequence of events, e.g. 'action 1 has to be .... Great stuff - just posted something else (and read your post after): ...
Time and Archaeological Event down into a sequence of multiple events of shovelling,. which are unlikely to be discernible. ..... time scales, though many post-processual accounts of ...
Collecting Event Histories with TrueTales: Techniques to Improve ... to at least approximate it. They explore all kinds of temporal connections. between events, such as “earlier than”, “after”, “during”, and “Time elapsed ...

Videos:
XML11: An Abstract Windowing Protocol Google TechTalks June 1, 2006 Arno Puder Arno Puder received his masters and Ph.D. in computer science and is currently working as an Assistant Prof...
Charlie Rose - Guest Host Dr. Harold Varmus with neurobiologist Dr. Eric Kandel Nobel laureate Dr. Harold Varmus, Chairman & CEO of Memorial Sloan-Kettering Cancer Center, serves as guest host for this conversation with neurobiol...
Zeitgeist, The Movie | Final Edition [ ENGLISH subtitles ] Zeitgeist, The Movie | Final Edition [ ENGLISH subtitles ]
Objects: they just work Google London Test Automation Conference (LTAC) Google Tech Talks September 8th, 2006 Presenter: Bob Binder
Marco Borrillo vs. Robert Bryant Jr. - Arizona Open Singles RR - Table Tennis Marco Borrillo vs. Robert Bryant Jr. - Arizona Open Singles RR - Table Tennis Ping Pong Tournament Arizona Online - Desert Table Tennis Outpost htt...




Search This Site:










any comments or suggestions for this code?

i can not get outlining work in aspx file?

general dotnetnuke questions

testing dnn2.0 alpha >> ms access >> add table

portalstore 6.5

usercontrol in webpart

about treeview

how use template to create new website?

media library starter kit

impersonation during asynchronous web service calls from web parts

how to set the registry key

preventing xss - why prefer double quotes rather than single quotes

2 same web parts on same page

uploading skins - 3.08

expert help needed

dynamically loading user controls

core team chat highlights [feb 09]

no control after button click

help needed with backing up outlook email folders and settings

connection to sql express from vs2005

delegating to a custom profile provider

newbie help with structuring web application project

need to contact someone who can help with intranet

sqldatasource and membership id

3.0 best practices: when joining tables, do i create separate info and controller classes?

website project vs. web application project in visual studio.net 2005

convert createuserwizard handler from c# to vb

gridview adapter skips colum style

tabstrip control in asp.net v2

'nt authority\network service' vs 'machine name\aspnet'

 
All Times Are GMT