Visual Studio .NET - Me IsPostBack NOT working in the master page

Asked By Erik Little on 04-May-06 07:40 PM
For some reason the ispostback does not work in the master page like it does in the page 

I have  a tab menu at the top of my master page and for some reason on each and every post the Code below runs and i do not need that i only need that the first time the page loads ( the master page) for some reason when i link to another page  the isPostback first like its the first post...


what do i do about this?

erik 

----This code evaluated to false every post in the master page

   [CODE]If Not Me.IsPostBack Then
            Dim uC As UserControl = Nothing
            Dim mV As MultiView = Nothing
            uC = DirectCast(Me.FindControl("Tab_Master1"), UserControl)

            mV = DirectCast(uC.FindControl("Master_Tab_MultiView"), MultiView)
            mV.SetActiveView(DirectCast(mV.FindControl("Home"), View))
        End If [/CODE]

Link To Another Page Is Not A Postback - Asked By woo yowonn on 07-May-06 02:28 PM

Correct me if i'm wrong. My answer based on how i understand your question.

>"every post the Code below runs and i do not need that i only need that the first time the page loads " 

I reckon you only want the code inside the if statement run once when user visit your SITE since the if statement is in your master page.

>"for some reason when i link to another page the isPostback first like its the first post"

When you go to another page through a link, it is not a postback. Since your code to check Ispostback written in your masterpage, the code will exist in every page of your site. So 

If Not Me.IsPostBack Then 
/code/
End If

the condition of the if statement will always true when you browse other pages through a link. Code inside the if statement will execute. The code did the job exactly what you ask, but it's not what you expect.