Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I loved your article about "Inside Master Page". I now can hide a panel that I use for a menu.

My question is that I have placed a dropdownlist on the master and when I make a change, I want specific things to occur depending on the page that I am on.

Here is the code that I use to have on the content page when the dropdownlist was there as well.

 Protected Sub ddlPrintGroup_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlPrintGroup.SelectedIndexChanged
        On Error GoTo sub_error
        Dim strSub As String
        strSub = "ddlPrintGroup_SelectedIndexChanged"
        '================================================================================
        myddlLocs.SelectedIndex = -1
        PreviewReport()
        '================================================================================
sub_exit:
        Exit Sub
sub_error:
        If mytxtMsg.Text = "" Then
            mytxtMsg.Text = "Error in Sub " & strSub & " - " & Err.Number & " : " & Err.Description
        End If
        mytxtMsg.Visible = True
    End Sub


I have added a variable called the following at the top of the class:
Public myddlPrintGroup As DropDownList


In the Page_Init, I have the following:

myddlPrintGroup = CType(myMaster.FindControl("ddlPrintGroup"), DropDownList)


How do I get the subroutine ddlPrintGroup_SelectedIndexChanged to look at the myddlPrintGroup that is on the master page?

Thanks!
Eddi Rae
Posted

1 solution

wrote:
I loved your article about "Inside Master Page".


If you want to talk to an article author, there's a forum under the article.

Use a delegate to hook the event up in each page that you write.


wrote:
myddlPrintGroup = CType(myMaster.FindControl("ddlPrintGroup"), DropDownList)


Instead of nasty code like this, you should provide a custom base page class, which strongly types your master page in a property, then you can expose things like delegates and properties on it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900