Wrox Programmer Forums
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 10th, 2008, 02:09 PM
Registered User
Join Date: Feb 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Postback problem

I have a problem at the moment with a web project.

I have two Panels within an UpdatePanel on an aspx page (using Masterpages). I'm using ASP.Net 2.0 with an AJAX enabled website.

The two Panels represent a Master-Detail type relationship. I want a user to click a LinkButton in the first Panel and then for the 2nd Panel to be displayed with the detail.

However, I need to set some text properties of textboxes programmatically when the LinkButton is clicked.

The problem, though, is that the UpdatePanel's Load event fires BEFORE the LinkButton's click event. The data needs to be in the textboxes before the UpdatePanel's Load event fires, as it renders items depending upon this data.

I was wondering if a client-side solution might work?

Is there a way I could wire the "OnClientClick" of the LinkButton to a client-side JavaScript function that would write the appropriate text to a hidden field or other control or variable that could be then read in the code behind when the UpdatePanel's Load event fires?

Or, is there an easier or better way of doing this? Am I missing something on the event sequence for the UpdatePanel??

The linkbutton is in the ItemTemplate of the gridview on each row.

The gridview is in a Panel which is in an UpdatePanel. This is the "master" view, containing a list of data items. The UpdatePanel also contains another Panel. This second panel is the details view, which should display the details of a selected item the user picks from the first panel.

But, both the panels in the UpdatePanel reside in the same space. So, when the user selects an item, the master panel becomes invisible and the details panel is in view.

I want to click on the link button and then view the details in another panel, with the master panel becoming invisible.

The project I am working on is a little different in that an XML datasource is being used via a bespoke provider, so I can't quite link things up the way described above. However, I have tried this with the appropriate adjustment, using the HyperLinkField.

It has been suggested to me to use a HyperLinkField that maps a value to a QueryString parameter. This would certainly work. However, it does not look like it's a suitable solution as there is a more general issue in that this is an AJAX enabled website.

The idea of the UpdatePanel, and the two normal Panels within, is that the transition should be visibly seamless between viewing a list of data items in the master view (in the 1st panel) and the details of a particular selected item in the details view (the 2nd panel).

In other words, it relies upon a partial page postback on the UpdatePanel.

However, when the link for a hyperlink control or hyperlinkfield is clicked, the page is requested as a completely new request and therefore does not cause a postback to occur. This results in the whole page loading again, which is not what is desired here.

The project also uses a masterpage.

The UploadPanel has both Load() and PreRender() events. Within these events is the code that determines which panel is displayed upon a partial page postback. So, prior to the content of these event handlers executing, I need to determine which item was selected from the GridView (each item in the Grid is identified by a unique string ID).

I am now struggling a little with this one. I've been through a few books and am still not getting anywhere. Frustrating.

Any help much appreciated on this.

Thanks - Darren

Old April 10th, 2008, 11:46 PM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts


It doesn't sound like you have the code that loads the detail panel in the correct place. This panel is really the "child" of the master panel grid view, so it should be manipulated based on the events at the grid.

I would recommend that you move the code that loads the detail panel from the page load handler into a separate method. Then set up calls to it from wherever you need to. This could be either:

1) The grid view button click handler (the logical location based on the event sequence)
2) The page PreRender handler. This fires after all postback event handlers so you're guaranteed to have captured all user actions by this point.

Old April 17th, 2008, 12:56 AM
Registered User
Join Date: Apr 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

i know that problem, thanks for your help i will try to solve


Old May 8th, 2008, 01:02 AM
Registered User
Join Date: May 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

sounds is like i hope i will do it


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with viewstate and postback hertendreef ASP.NET 2.0 Professional 1 May 31st, 2008 04:05 PM
Postback Problem dbrook007 ASP.NET 2.0 Professional 1 April 1st, 2008 06:16 AM
Problem with Postback and Multiviews ftm BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 August 16th, 2007 09:19 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.