---
title: "PreviousPage.FindControl + MasterPage"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/170352-previouspage-findcontrol-masterpage"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "Arne"
published: "2008-03-31T10:25:12.000Z"
updated: "2008-04-02T14:10:40.000Z"
replies: 3
views: 455
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/170352-previouspage-findcontrol-masterpage"
---

# PreviousPage.FindControl + MasterPage

## #1 — Arne, 2008-03-31T10:25Z

Har en PreviousPage.FindControl  som fungerar utan problem på sidor som ej är MasterPage.
Använder jag mig av MasterPage så fungerar ej FindControl?

Page.PreviousPage fungerar, men ej PreviousPage.FindControl
Vad gör jag för fel när jag använder MasterPage?

```
If Not Page.PreviousPage Is Nothing Then
	Dim SourceLabel As Label
	SourceLabel = CType(PreviousPage.FindControl("lblMyId"), Label)
	If Not SourceLabel Is Nothing Then
		lblPickUpId.Text = SourceLabel.Text
	End If
Else
	lblPickUpId.Text = lblPickUpId.Text
End If
```

Permalänk: https://www.webforum.nu/p/170352

## #2 — Travoni, 2008-03-31T15:52Z

Testa detta:

```
SourceLabel = CType(PreviousPage.FindControlByID(PreviousPage.Controls,"lblMyId"), Label)

Public Shared Function FindControlByID(ByVal controls As ControlCollection, ByVal id As String) As Control
            Dim found As Control = Nothing
            For Each control As Control In controls
                If control.ID = id Then
                    Return control
                End If
                If control.HasControls() Then
                    found = FindControlByID(control.Controls, id)
                    If found IsNot Nothing Then
                        Return found
                    End If
                End If
            Next
            Return found
        End Function
```

Permalänk: https://www.webforum.nu/p/2094857

## #3 — Arne, 2008-04-01T06:19Z

System.Web.UI.Page

Jag får: 'FindControlByID' is not a member of 'System.Web.UI.Page'.

Hittar inte vad det beror på.......

Permalänk: https://www.webforum.nu/p/2094948

## #4 — Travoni, 2008-04-02T14:10Z

SourceLabel = CType(Me.FindControlByID(PreviousPage.Controls,"lblMyId"), Label)

Permalänk: https://www.webforum.nu/p/2095309

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/170352-previouspage-findcontrol-masterpage
