Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 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 January 9th, 2007, 05:43 AM
Authorized User
 
Join Date: Mar 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Registering ASCX

Hi

I have a problem with a site I've inherited, the main page has a lot of register directives (about 30 of them) like so

<%@ Register TagPrefix="UserAddress" TagName="Delete" Src="includes/UserAddress_delete.ascx" %>
<%@ Register TagPrefix="UserAddress" TagName="Edit" Src="includes/UserAddress_edit.ascx" %>
<%@ Register TagPrefix="UserAddress" TagName="Show" Src="includes/UserAddress.ascx" %>

The further down the code there is a long case statement for every one of these like so, ActivePage and ActiveSubPage are a couple of variables defined in page_load from request.querystring.
select case activePage

Case "usermanagement"
    Select Case ActiveSubPage.ToLower
    Case "edit","add"
%>
        <USERMANAGEMENTEDIT:SHOW id="Show16" RunAt="server"></USERMANAGEMENTEDIT:SHOW>
<%
    Case "delete"
%>
        <USERMANAGEMENTDELETE:SHOW id="Show17" RunAt="server"></USERMANAGEMENTDELETE:SHOW>
<%
    case else
%>
        <USERMANAGEMENT:SHOW id="Show7" RunAt="server"></USERMANAGEMENT:SHOW>
<%
    end select

This code is running really slowly, I've traced the code through and the page_load for every one of the ascx files is getting executed before the page displays and takes several minutes.

The only way I can see to fix this is to make the case statement redirect a new page and register the ascx to that
e.g.
create user_management_edit.aspx and register the tagprefix for just edit
create user_management_delete.aspx and register the tagprefix for just delete
create user_management_show.aspx and register the tagprefix for just show

This is a fairly major rewrite but I can't see any other way around it. I'd appreciate it if anyone could let me know if there is a better way.

Regards
Graham


 
Old January 9th, 2007, 11:57 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

ICK!! You're the unfortunate victim of someone else's VERY bad page design.

In proper page construction you should hardly ever need to use the <% %> syntax of classis ASP.

The "@ Register" directives are OK and won't make the page slower. But you could remove them because my suggestion will not need them.

What you need to change is you need to remove all the instances of the controls from the markup. Then in the page's code-behind, use the same logic and dynamically load the appropriate control using the Page.LoadControl() method. Then only the page load method for the actual control you load will run. You could put an asp:placeholder control on the page in place of all the control markup.

Here's an example (It might not be perfect, coming from memory):

plcSubPage.Controls.Add(Me.LoadControl("includes/UserAddress_delete.ascx"))

This would add just the UserAddress_delete user control to the page.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Registering users Glaman BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 March 5th, 2008 07:39 PM
Email Registering HelpWanted ASP.NET 1.0 and 1.1 Basics 1 September 20th, 2006 04:21 PM
Registering a new user hasanali00 BOOK: ASP.NET Website Programming Problem-Design-Solution 4 April 14th, 2005 05:07 AM
Registering DLL's askenkray Classic ASP Components 4 January 27th, 2005 03:05 PM
Registering a new user ssaylanc BOOK: ASP.NET Website Programming Problem-Design-Solution 4 January 9th, 2005 04:34 PM





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