Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesEvent sequence - Page Load vs. Button ClickEvent sequence - Page Load vs. Button Click
Previous
 
Next
New Post
1/26/2010 10:32 AM
 

This has been discussed on the Web and it's not really a DNN-specific question but from what I can see the solutions people talk about can't really be applied here.  I come from a WinForms background, all things ASP.NET are still quite new to me, so it must be something really simple I am missing.

The DNN module I am designing is called "Job".  Each Job could have multiple attachments. I have a DataList control on my module which lists all attachments on that job.  Currently fields like JobName, JobDate, etc. and the DataList (which is bound) are being populated from DB in the Page_Load event.  Now, let's say I would like to remove one of the attachments.  I have a button in the item template of the DataList.  The problem is - when the button is clicked it calls the Page_Load first (which populates the DataList) and then the button click event (which deletes the record from DB).  This really need to happen in reverse - delete first, then populate list.

The solution I was able to find on various forums is to use Page_LoadComplete event instead of Page_Load, that will be fired after the button click event.  The problem is - I don't have the Page_LoadComplete event because DNN modules are really Web User Controls.

Any suggestions for me?

Thank you very much,

Alex

 

 
New Post
1/26/2010 1:53 PM
Accepted Answer 

Page_LoadComplete is not the appropriate approach to this. It is normal ASP.Net behavior for Page_Load handler to be called both when the control is first loaded AND upon each postback - thus, Page_Load event will always be raised and handled before your button click event. The correct approach is to bind data - such as to your DataList only on the initial Page_Load but not on postbacks . . . like this:

'in Page_Load handler:

If Not Page.IsPostBack Then
      PopulateMyDataList()
End If

In your button handler you will also need to re-populate the DataList following the deletion of an item.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
1/26/2010 4:25 PM
 

Thank you.  I did just that while waiting for a reply and it works now.  It's good to know I took the right approach.

Thanks again!

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesEvent sequence - Page Load vs. Button ClickEvent sequence - Page Load vs. Button Click


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out