webForumDet fria alternativet

PreviousPage.FindControl + MasterPage

3 svar · 438 visningar · startad av Arne

ArneMedlem sedan maj 2000267 inlägg
#1

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
TravoniMedlem sedan okt. 20041 556 inlägg
#2

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
ArneMedlem sedan maj 2000267 inlägg
#3

System.Web.UI.Page

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

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

TravoniMedlem sedan okt. 20041 556 inlägg
#4

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

126 ms totalt · 3 externa anrop · v20260731065814-full.30151723
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
124 ms — hämta tråd, inlägg och bilagor (db)