I've been tasked with modifying a previous developers user control code so that it doesnt access the dbase as inefficiently as it does. What is happening is dynamic hyperlink controls are being created and inserted into personal Panels then each is added
to a WebControl container. The result, from the HTML output, are hyperlinks like:
<a href="javascript:__doPostBack('_ctl3$DesktopThreePanes1$ThreePanes$_ctl5$tcItems$_ctl1$_ctl0','')" ItemID="954" RecordType="Orgs">Garden Centre & Landscaping Inc.</a>
</div>
Of course the <div></div> elements are the user control container.
With respect to the dynamic hyperlinks the class declaration is as follows:
public class
ServerLink: System.Web.UI.WebControls.HyperLink, IPostBackEventHandler, INamingContainer
{}
Within the class a couple properties are implemented which GET or SET the
ViewState object with athe id "ItemID" and "RecordType". Also implemented is:
My situation is when the page is hit for the first time (!IsPostBack) the dbase is hit and the page is dynamically created with over 50 hyperlinks. When the user clicks one of the hyperlinks it performs a POSTBACK to the page.
What is supposed to happen is the postback will eventually trigger for a details page on the single hyperlink clicked. This does happen once the hyperlink click event is called but before this happens the control goes thru its routine of calling the dbase
to compose the original dynamic controls. Interestingly the recreated display is hidden from view and never used. Eventually the hyperlink event is called and performs the routine of accessing the dbase for the specific detail for actual display (the original
hyperlink list remains hidden from view).
My understanding of the above is the original developer could not get the hyperlink event to fire unless the original page was recreated in full. I'm in a situation where I need to stop this wasteful dbase access on post back but still would like to identify
what hyperlink was clicked so that I can call the dbase for the details info. How do i achieve this?
I can see each hyperlink control has a unique ID on post back but the attributes of interest are the "ItemID" and "RecordType" values that are also unique for each hyperlink. How do i extract this information, whereever they are hiding, on post back? If
I stop the recreation of the dynamic hyperlinks via the dbase on postback, the user-clicked hyperlink event is never fired, and so Im not any closer to identifying what the ItemID and RecordType selected by the user.
quantass0
Member
275 Points
117 Posts
IMPOSSIBLE? Dynamic Hyperlink attributes on Postback
May 07, 2006 10:37 PM|LINK
I've been tasked with modifying a previous developers user control code so that it doesnt access the dbase as inefficiently as it does. What is happening is dynamic hyperlink controls are being created and inserted into personal Panels then each is added to a WebControl container. The result, from the HTML output, are hyperlinks like:
<div id="_ctl3_DesktopThreePanes1_ThreePanes__ctl5_tcItems" class="TRSM_TourismControl">
<a href="javascript:__doPostBack('_ctl3$DesktopThreePanes1$ThreePanes$_ctl5$tcItems$_ctl0$_ctl0','')" ItemID="432" RecordType="Orgs">ational Historic Site</a>
<a href="javascript:__doPostBack('_ctl3$DesktopThreePanes1$ThreePanes$_ctl5$tcItems$_ctl1$_ctl0','')" ItemID="954" RecordType="Orgs">Garden Centre & Landscaping Inc.</a>
</div>
Of course the <div></div> elements are the user control container.
With respect to the dynamic hyperlinks the class declaration is as follows:
public class ServerLink: System.Web.UI.WebControls.HyperLink, IPostBackEventHandler, INamingContainer
{}
Within the class a couple properties are implemented which GET or SET the ViewState object with athe id "ItemID" and "RecordType". Also implemented is:
void
IPostBackEventHandler.RaisePostBackEvent(string eventArgument) {}Within the
My situation is when the page is hit for the first time (!IsPostBack) the dbase is hit and the page is dynamically created with over 50 hyperlinks. When the user clicks one of the hyperlinks it performs a POSTBACK to the page. What is supposed to happen is the postback will eventually trigger for a details page on the single hyperlink clicked. This does happen once the hyperlink click event is called but before this happens the control goes thru its routine of calling the dbase to compose the original dynamic controls. Interestingly the recreated display is hidden from view and never used. Eventually the hyperlink event is called and performs the routine of accessing the dbase for the specific detail for actual display (the original hyperlink list remains hidden from view).
My understanding of the above is the original developer could not get the hyperlink event to fire unless the original page was recreated in full. I'm in a situation where I need to stop this wasteful dbase access on post back but still would like to identify what hyperlink was clicked so that I can call the dbase for the details info. How do i achieve this?
I can see each hyperlink control has a unique ID on post back but the attributes of interest are the "ItemID" and "RecordType" values that are also unique for each hyperlink. How do i extract this information, whereever they are hiding, on post back? If I stop the recreation of the dynamic hyperlinks via the dbase on postback, the user-clicked hyperlink event is never fired, and so Im not any closer to identifying what the ItemID and RecordType selected by the user.
Thanks.