[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

Retrieve top level master page from BasePage

Asked by ddl_ex5 in Programming for ASP.NET, .NET Framework 2.x

Hey,

I have a web app which has a BasePage.vb in the app_code which all my aspx pages inherit from throughout the entire web app.

I have a root site.master page, then at each level could be 5 folders deep i have a app.master page.i.e.

I have a section of code on my site.master (panel with controls to display on page).
On my BasePage i have a public sub which can get called from any of the aspx pages which should look for the root master page to fin the panel and controls and display the emssage accrodingly.

My issue is I do not want to use a RecursiveControl finnder to get to the root master page.

Please see my code as clear explaintions

The code works but I have read articles like http://www.oshyn.com/BlogRetrieve.aspx?BlogID=2583&PostID=76470 which state that performance is going ot be a problem, and the last thing i want is to slow down the web app.

also looked at http://weblogs.asp.net/scottgu/archive/2005/11/11/430382.aspx but i do not want to set the root master page at runtime as each master page is laid out different where some have some contentplaceholders and some don't.

many thanks in advance for your help



1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
Site.master
<asp:Panel ID="myPanel" runat="server">
        <asp:Label ID="lbl1" runat="server" CssClass="status_title" />
        <br />
        <asp:Label ID="lbl2" runat="server" />
    </asp:Panel>
 
BasePage
    Public Sub Alert(ByVal message As String, Optional ByVal type As prompt_type = prompt_type.type_error)
        Dim myPanelAs Panel = DirectCast(FindControlRecursive(Page, "myPanel"), Panel)
        Dim lbl1As Label = DirectCast(FindControlRecursive(Page, "lbl1"), Label)
        Dim lbl2 As Label = DirectCast(FindControlRecursive(Page, "lbl2"), Label)
 
//do my code
    End Sub
 
    Public Shared Function FindControlRecursive(ByVal root As Control, ByVal id As String) As Control
        If id = String.Empty Then
            Return Nothing
        End If
 
        If root.ID = id Then
            Return root
        End If
 
        For Each c As Control In root.Controls
            Dim t As Control = FindControlRecursive(c, id)
            If t IsNot Nothing Then
                Return t
            End If
        Next
        Return Nothing
    End Function
 
default.aspx 
<%@ Page Language="VB" MasterPageFile="~/test/test2/test3/test4/test5/app.master" CodeFileBaseClass="BasePage" 
AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="testDefault" Title="test" %>
 
default.aspx.vb
        Try
            Dim sql As New SqlDatabase
            Dim dt As DataTable = sql.FillDataTable("testingfolder5")
        Catch ex As Exception
            Alert(ex.Message)
        End Try
[+][-]10/27/09 09:30 AM, ID: 25674398Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Programming for ASP.NET, .NET Framework 2.x
Sign Up Now!
Solution Provided By: ddl_ex5
Participating Experts: 1
Solution Grade: A
 
[+][-]10/22/09 09:08 PM, ID: 25641303Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/26/09 06:36 AM, ID: 25662060Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/26/09 09:29 PM, ID: 25669136Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625