Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Setting the value of a Master page's control's property using a property of the Master page

Reply
Thread Tools

Setting the value of a Master page's control's property using a property of the Master page

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      03-01-2010
Thanks. I was working on figuring out what's wrong, and although I haven't
found an answer, I did find something that if I spend a few weeks pulling my
hair out looking at, might get me a solution. I was looking at the
LoadControl method. The problem is, it seems very inefficient (if possible)
to use it to solve my problem. No problem being late with the code, my
family was here over the weekend, so I was busy until now anyway. Hope to
hear from you soon!
--
Nathan Sokalski

http://www.nathansokalski.com/

"Sergey Poberezovskiy" <> wrote
in message news:061004E9-E62E-4C5A-B9D1-...
> Sorry man - forgot again
>
> I will send myself a reminder email - so you can expect some code tomorrow
> if it is still required...
>
>
> "Nathan Sokalski" wrote:
>
>> Unfortunately, that code isn't helping. When I tried changing my PreInit
>> to:
>>
>> Private Sub Page_PreInit(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles Me.PreInit
>> If Me.Master.Master Is Nothing Then Me.Master.SelectedNavigationID =
>> "menuConditionalValidator"
>> End Sub
>>
>> It gave me the same error I was getting before, since Me.Master.Master Is
>> Nothing evaluates to True.
>>
>> I am using PreInit to set a property of a UserControl I created for the
>> navigation on my site. If this property is not set, the navigation
>> hierarchy
>> will be collapsed and not have the current page highlighted. If you go to
>> my
>> website, you can see this UserControl on the left side of all the pages
>> (my
>> live site is still working, because I haven't tried to update it since I
>> started having this problem when debugging it at home).
>> --
>> Nathan Sokalski
>>
>> http://www.nathansokalski.com/
>>
>> "Sergey Poberezovskiy" <>
>> wrote
>> in message news:527D721D-A86D-430C-B35B-...
>> > Nathan,
>> >
>> > I'm sorry I forgot to lookup the code for you - when I got back home, I
>> > got
>> > carried away with family stuff.
>> >
>> > From memory, to initiate MasterPage child control, I had to call on its
>> > Master property - this caused the whole control tree to load. Something
>> > like:
>> > If Me.Master.Master Is Nothing Then
>> > Me.Master.SelectedNavigationID = value
>> > End If
>> >
>> > Though it looks like a hack, but it does the job (if I remember
>> > correctly) -
>> > give it a shot. If you have a hierarchy of Master pages, you might need
>> > to
>> > do
>> > even more levels, something like:
>> > If Me.Master Is Nothing OrElse Me.Master.Master Is Nothing OrElse ...
>> >
>> > I use PreInit event to populate data controls without adding the data
>> > into
>> > ViewState - what is your reason?
>> >
>> >
>> > "Nathan Sokalski" wrote:
>> >
>> >> Thank you for your response, I look forward to seeing your code
>> >> (hopefully
>> >> it will help me solve the problem). The line that the error actually
>> >> occurs
>> >> on if I debug is:
>> >>
>> >> Private Sub Page_PreInit(ByVal sender As Object, ByVal e As
>> >> System.EventArgs) Handles Me.PreInit
>> >> Me.Master.SelectedNavigationID = "menuConditionalValidator"
>> >> End Sub
>> >>
>> >> which is in the Content Page. However, I originally tried placing a
>> >> breakpoint on this line to see whether Me.Master was Nothing or not,
>> >> but
>> >> it
>> >> was perfectly fine, so I then moved the breakpoint to the Set method
>> >> of
>> >> the
>> >> SelectedNavigationID property in:
>> >>
>> >> Public Property SelectedNavigationID() As String
>> >> Get
>> >> Return Me.leftnavNavigation.SelectedNavigationID
>> >> End Get
>> >> Set(ByVal value As String)
>> >> Me.leftnavNavigation.SelectedNavigationID = value
>> >> End Set
>> >> End Property
>> >>
>> >> where I found out that the object that was actually Nothing was
>> >> Me.leftnavNavigation. I doubt that the problem is in leftnavNavigation
>> >> (although who knows at this point), since it didn't give me any
>> >> problems
>> >> in
>> >> the project before (but neither did anything else) and I haven't
>> >> changed
>> >> anything, not to mention that it is Nothing at this point, so the only
>> >> place
>> >> the problem could be is in initialization, and I'm guessing I would
>> >> get
>> >> some
>> >> other error if that was the problem (but I could be wrong). Anyway, I
>> >> look
>> >> forward to seeing your code, and if you think seeing any of my code
>> >> will
>> >> help, just let me know (I just don't want to sent huge amounts of code
>> >> that
>> >> won't help anybody, but I am willing to share any code I write with
>> >> anybody
>> >> who is interested). Thank you again for all your effort, it's good to
>> >> know
>> >> there are people that really care about helping.
>> >> --
>> >> Nathan Sokalski
>> >>
>> >> http://www.nathansokalski.com/
>> >>
>> >> "Sergey Poberezovskiy" <>
>> >> wrote
>> >> in message news:B46F26A9-B59C-4BC7-837C-...
>> >> > Nathan,
>> >> >
>> >> > It looks like now the problem is in eftnavNavigation control (or its
>> >> > SelectedNavigationID) property.
>> >> > Try to put a breakpoint on the setter and see whether you can read a
>> >> > value
>> >> > from the SelectedNavigationID property - then you might be able to
>> >> > set
>> >> > it.
>> >> >
>> >> > I had similar problem trying to access Master page controls from the
>> >> > page
>> >> > on
>> >> > PreInit event, when not all child controls (including Master page
>> >> > control)
>> >> > are initialised. Unfortunately, I do not have the code handy - I
>> >> > will
>> >> > post
>> >> > it
>> >> > (if I can find it) in the next 8-10 hours.
>> >> >
>> >> > "Nathan Sokalski" wrote:
>> >> >
>> >> >> I tried that by changing my code from:
>> >> >>
>> >> >> Public Property SelectedNavigationID() As String
>> >> >> Get
>> >> >> Return Me.leftnavNavigation.SelectedNavigationID
>> >> >> End Get
>> >> >> Set(ByVal value As String)
>> >> >> Me.leftnavNavigation.SelectedNavigationID = value
>> >> >> End Set
>> >> >> End Property
>> >> >>
>> >> >> To:
>> >> >>
>> >> >> Public Property SelectedNavigationID() As String
>> >> >> Get
>> >> >> Me.EnsureChildControls()
>> >> >> Return Me.leftnavNavigation.SelectedNavigationID
>> >> >> End Get
>> >> >> Set(ByVal value As String)
>> >> >> Me.EnsureChildControls()
>> >> >> System.Diagnostics.Debug.WriteLine(IsNothing(Me.le ftnavNavigation))
>> >> >> Me.leftnavNavigation.SelectedNavigationID = value
>> >> >> End Set
>> >> >> End Property
>> >> >>
>> >> >> Not only does the Debug.WriteLine output the value True, but I
>> >> >> still
>> >> >> get
>> >> >> the
>> >> >> same error saying "Object reference not set to an instance of an
>> >> >> object.".
>> >> >> Unless I used the EnsureChildControls() method incorrectly here, it
>> >> >> unfortunately did not solve the problem. Any other ideas? Thanks.
>> >> >> --
>> >> >> Nathan Sokalski
>> >> >>
>> >> >> http://www.nathansokalski.com/
>> >> >>
>> >> >> "Sergey Poberezovskiy"
>> >> >> <>
>> >> >> wrote
>> >> >> in message
>> >> >> news:B1B794F2-9B52-4D60-8ED8-...
>> >> >> > Nathan,
>> >> >> >
>> >> >> > Take a look at the following link:
>> >> >> > http://msdn.microsoft.com/en-us/libr...dcontrols.aspx
>> >> >> >
>> >> >> > This looks like the solution to your problem.
>> >> >> >
>> >> >> > "Nathan Sokalski" wrote:
>> >> >> >
>> >> >> >> I have a Master page that contains a custom property, defined as
>> >> >> >> follows:
>> >> >> >>
>> >> >> >>
>> >> >> >> Public Property SelectedNavigationID() As String
>> >> >> >> Get
>> >> >> >> Return Me.leftnavNavigation.SelectedNavigationID
>> >> >> >> End Get
>> >> >> >> Set(ByVal value As String)
>> >> >> >> Me.leftnavNavigation.SelectedNavigationID = value
>> >> >> >> End Set
>> >> >> >> End Property
>> >> >> >>
>> >> >> >>
>> >> >> >> As you can see, this property is used to set the value of a
>> >> >> >> property
>> >> >> >> of
>> >> >> >> one
>> >> >> >> of the Master page's Controls. I set the property from the
>> >> >> >> Content
>> >> >> >> page
>> >> >> >> as
>> >> >> >> follows:
>> >> >> >>
>> >> >> >>
>> >> >> >> Private Sub Page_PreInit(ByVal sender As Object, ByVal e As
>> >> >> >> System.EventArgs) Handles Me.PreInit
>> >> >> >> Me.Master.SelectedNavigationID = "menuConditionalValidator"
>> >> >> >> End Sub
>> >> >> >>
>> >> >> >>
>> >> >> >> The problem occurs in the Set method of the property defined in
>> >> >> >> the
>> >> >> >> Master
>> >> >> >> page; it tells me that Me.leftnavNavigation has a value of
>> >> >> >> Nothing,
>> >> >> >> which
>> >> >> >> obviously prevents me from setting the property. I know that I
>> >> >> >> am
>> >> >> >> missing
>> >> >> >> something simple, because this is almost exactly the same as a
>> >> >> >> previous
>> >> >> >> version of the site I am recreating, which works perfectly. What
>> >> >> >> could
>> >> >> >> be
>> >> >> >> causing the problem? Any help would be appreciated. Thanks.
>> >> >> >> --
>> >> >> >> Nathan Sokalski
>> >> >> >>
>> >> >> >> http://www.nathansokalski.com/
>> >> >> >>

 
Reply With Quote
 
 
 
 
Andy O'Neill
Guest
Posts: n/a
 
      03-01-2010
"Nathan Sokalski" <> wrote in message
news4549F53-30CC-4004-A51E-...
>I have, and I think I do, but either way, I'm not sure what events are left
>for me to put it in. If you don't want to or can't help me, then just don't
>reply to the posts, the purpose of these newsgroups is to help our fellow
>developers solve there problems, there is no better way to learn more about
>anything than seeing the answer hands-on, even if you do need some help
>figuring out what that answer is. Thanks.


Just giving someone a piece of code doesn't teach them anything other than
how to cut and paste.
They have not explored the issue so they have no idea on whether the code is
good or bad.

Here's several answers.
I already gave you one of these.

Quick but AWFUL fix
Persist your property in viewstate.
Don't update it in postback.

BAD fix:
Use an object to drive the menu.
Cache it in session.
Update in content pages.
Read in master page.

Best fix.
Completely change the way your navigation works.
It makes you look bad.


I was particularly amused by this part:

>If you don't want to or can't help me, then just don't
> reply to the posts,


Oh, the irony.
If you just don't want or like my advice how about you don't bitch and whine
about it.



 
Reply With Quote
 
 
 
 
Sergey Poberezovskiy
Guest
Posts: n/a
 
      03-01-2010
Nathan,

I was wright - I use Master.Master to initilise the control tree - strangely
enough I do not have comments explaining the reason (as I usually do).
The code, however, is wrapped in a try catch, and if not succeeded, then
called again from Init - again, not sure why - has been quite a few years now
- but seems to be working ...

Could you try to create a small project that consistently recreates the
problem, and send it to - I will have a look at it for
you

"Nathan Sokalski" wrote:

> Thanks. I was working on figuring out what's wrong, and although I haven't
> found an answer, I did find something that if I spend a few weeks pulling my
> hair out looking at, might get me a solution. I was looking at the
> LoadControl method. The problem is, it seems very inefficient (if possible)
> to use it to solve my problem. No problem being late with the code, my
> family was here over the weekend, so I was busy until now anyway. Hope to
> hear from you soon!
> --
> Nathan Sokalski
>
> http://www.nathansokalski.com/
>
> "Sergey Poberezovskiy" <> wrote
> in message news:061004E9-E62E-4C5A-B9D1-...
> > Sorry man - forgot again
> >
> > I will send myself a reminder email - so you can expect some code tomorrow
> > if it is still required...
> >
> >
> > "Nathan Sokalski" wrote:
> >
> >> Unfortunately, that code isn't helping. When I tried changing my PreInit
> >> to:
> >>
> >> Private Sub Page_PreInit(ByVal sender As Object, ByVal e As
> >> System.EventArgs) Handles Me.PreInit
> >> If Me.Master.Master Is Nothing Then Me.Master.SelectedNavigationID =
> >> "menuConditionalValidator"
> >> End Sub
> >>
> >> It gave me the same error I was getting before, since Me.Master.Master Is
> >> Nothing evaluates to True.
> >>
> >> I am using PreInit to set a property of a UserControl I created for the
> >> navigation on my site. If this property is not set, the navigation
> >> hierarchy
> >> will be collapsed and not have the current page highlighted. If you go to
> >> my
> >> website, you can see this UserControl on the left side of all the pages
> >> (my
> >> live site is still working, because I haven't tried to update it since I
> >> started having this problem when debugging it at home).
> >> --
> >> Nathan Sokalski
> >>
> >> http://www.nathansokalski.com/
> >>
> >> "Sergey Poberezovskiy" <>
> >> wrote
> >> in message news:527D721D-A86D-430C-B35B-...
> >> > Nathan,
> >> >
> >> > I'm sorry I forgot to lookup the code for you - when I got back home, I
> >> > got
> >> > carried away with family stuff.
> >> >
> >> > From memory, to initiate MasterPage child control, I had to call on its
> >> > Master property - this caused the whole control tree to load. Something
> >> > like:
> >> > If Me.Master.Master Is Nothing Then
> >> > Me.Master.SelectedNavigationID = value
> >> > End If
> >> >
> >> > Though it looks like a hack, but it does the job (if I remember
> >> > correctly) -
> >> > give it a shot. If you have a hierarchy of Master pages, you might need
> >> > to
> >> > do
> >> > even more levels, something like:
> >> > If Me.Master Is Nothing OrElse Me.Master.Master Is Nothing OrElse ...
> >> >
> >> > I use PreInit event to populate data controls without adding the data
> >> > into
> >> > ViewState - what is your reason?
> >> >
> >> >
> >> > "Nathan Sokalski" wrote:
> >> >
> >> >> Thank you for your response, I look forward to seeing your code
> >> >> (hopefully
> >> >> it will help me solve the problem). The line that the error actually
> >> >> occurs
> >> >> on if I debug is:
> >> >>
> >> >> Private Sub Page_PreInit(ByVal sender As Object, ByVal e As
> >> >> System.EventArgs) Handles Me.PreInit
> >> >> Me.Master.SelectedNavigationID = "menuConditionalValidator"
> >> >> End Sub
> >> >>
> >> >> which is in the Content Page. However, I originally tried placing a
> >> >> breakpoint on this line to see whether Me.Master was Nothing or not,
> >> >> but
> >> >> it
> >> >> was perfectly fine, so I then moved the breakpoint to the Set method
> >> >> of
> >> >> the
> >> >> SelectedNavigationID property in:
> >> >>
> >> >> Public Property SelectedNavigationID() As String
> >> >> Get
> >> >> Return Me.leftnavNavigation.SelectedNavigationID
> >> >> End Get
> >> >> Set(ByVal value As String)
> >> >> Me.leftnavNavigation.SelectedNavigationID = value
> >> >> End Set
> >> >> End Property
> >> >>
> >> >> where I found out that the object that was actually Nothing was
> >> >> Me.leftnavNavigation. I doubt that the problem is in leftnavNavigation
> >> >> (although who knows at this point), since it didn't give me any
> >> >> problems
> >> >> in
> >> >> the project before (but neither did anything else) and I haven't
> >> >> changed
> >> >> anything, not to mention that it is Nothing at this point, so the only
> >> >> place
> >> >> the problem could be is in initialization, and I'm guessing I would
> >> >> get
> >> >> some
> >> >> other error if that was the problem (but I could be wrong). Anyway, I
> >> >> look
> >> >> forward to seeing your code, and if you think seeing any of my code
> >> >> will
> >> >> help, just let me know (I just don't want to sent huge amounts of code
> >> >> that
> >> >> won't help anybody, but I am willing to share any code I write with
> >> >> anybody
> >> >> who is interested). Thank you again for all your effort, it's good to
> >> >> know
> >> >> there are people that really care about helping.
> >> >> --
> >> >> Nathan Sokalski
> >> >>
> >> >> http://www.nathansokalski.com/
> >> >>
> >> >> "Sergey Poberezovskiy" <>
> >> >> wrote
> >> >> in message news:B46F26A9-B59C-4BC7-837C-...
> >> >> > Nathan,
> >> >> >
> >> >> > It looks like now the problem is in eftnavNavigation control (or its
> >> >> > SelectedNavigationID) property.
> >> >> > Try to put a breakpoint on the setter and see whether you can read a
> >> >> > value
> >> >> > from the SelectedNavigationID property - then you might be able to
> >> >> > set
> >> >> > it.
> >> >> >
> >> >> > I had similar problem trying to access Master page controls from the
> >> >> > page
> >> >> > on
> >> >> > PreInit event, when not all child controls (including Master page
> >> >> > control)
> >> >> > are initialised. Unfortunately, I do not have the code handy - I
> >> >> > will
> >> >> > post
> >> >> > it
> >> >> > (if I can find it) in the next 8-10 hours.
> >> >> >
> >> >> > "Nathan Sokalski" wrote:
> >> >> >
> >> >> >> I tried that by changing my code from:
> >> >> >>
> >> >> >> Public Property SelectedNavigationID() As String
> >> >> >> Get
> >> >> >> Return Me.leftnavNavigation.SelectedNavigationID
> >> >> >> End Get
> >> >> >> Set(ByVal value As String)
> >> >> >> Me.leftnavNavigation.SelectedNavigationID = value
> >> >> >> End Set
> >> >> >> End Property
> >> >> >>
> >> >> >> To:
> >> >> >>
> >> >> >> Public Property SelectedNavigationID() As String
> >> >> >> Get
> >> >> >> Me.EnsureChildControls()
> >> >> >> Return Me.leftnavNavigation.SelectedNavigationID
> >> >> >> End Get
> >> >> >> Set(ByVal value As String)
> >> >> >> Me.EnsureChildControls()
> >> >> >> System.Diagnostics.Debug.WriteLine(IsNothing(Me.le ftnavNavigation))
> >> >> >> Me.leftnavNavigation.SelectedNavigationID = value
> >> >> >> End Set
> >> >> >> End Property
> >> >> >>
> >> >> >> Not only does the Debug.WriteLine output the value True, but I
> >> >> >> still
> >> >> >> get
> >> >> >> the
> >> >> >> same error saying "Object reference not set to an instance of an
> >> >> >> object.".
> >> >> >> Unless I used the EnsureChildControls() method incorrectly here, it
> >> >> >> unfortunately did not solve the problem. Any other ideas? Thanks.
> >> >> >> --
> >> >> >> Nathan Sokalski
> >> >> >>
> >> >> >> http://www.nathansokalski.com/
> >> >> >>
> >> >> >> "Sergey Poberezovskiy"
> >> >> >> <>
> >> >> >> wrote
> >> >> >> in message
> >> >> >> news:B1B794F2-9B52-4D60-8ED8-...
> >> >> >> > Nathan,
> >> >> >> >
> >> >> >> > Take a look at the following link:
> >> >> >> > http://msdn.microsoft.com/en-us/libr...dcontrols.aspx
> >> >> >> >
> >> >> >> > This looks like the solution to your problem.
> >> >> >> >
> >> >> >> > "Nathan Sokalski" wrote:
> >> >> >> >
> >> >> >> >> I have a Master page that contains a custom property, defined as
> >> >> >> >> follows:
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> Public Property SelectedNavigationID() As String
> >> >> >> >> Get
> >> >> >> >> Return Me.leftnavNavigation.SelectedNavigationID
> >> >> >> >> End Get
> >> >> >> >> Set(ByVal value As String)
> >> >> >> >> Me.leftnavNavigation.SelectedNavigationID = value
> >> >> >> >> End Set
> >> >> >> >> End Property
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> As you can see, this property is used to set the value of a
> >> >> >> >> property
> >> >> >> >> of
> >> >> >> >> one
> >> >> >> >> of the Master page's Controls. I set the property from the
> >> >> >> >> Content
> >> >> >> >> page
> >> >> >> >> as
> >> >> >> >> follows:
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> Private Sub Page_PreInit(ByVal sender As Object, ByVal e As
> >> >> >> >> System.EventArgs) Handles Me.PreInit
> >> >> >> >> Me.Master.SelectedNavigationID = "menuConditionalValidator"
> >> >> >> >> End Sub
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> The problem occurs in the Set method of the property defined in
> >> >> >> >> the
> >> >> >> >> Master
> >> >> >> >> page; it tells me that Me.leftnavNavigation has a value of
> >> >> >> >> Nothing,
> >> >> >> >> which
> >> >> >> >> obviously prevents me from setting the property. I know that I
> >> >> >> >> am
> >> >> >> >> missing
> >> >> >> >> something simple, because this is almost exactly the same as a
> >> >> >> >> previous
> >> >> >> >> version of the site I am recreating, which works perfectly. What
> >> >> >> >> could
> >> >> >> >> be
> >> >> >> >> causing the problem? Any help would be appreciated. Thanks.
> >> >> >> >> --
> >> >> >> >> Nathan Sokalski
> >> >> >> >>
> >> >> >> >> http://www.nathansokalski.com/
> >> >> >> >>

 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      03-03-2010
Good (I mean great!) News! I finally found the problem! I don't know why it
was causing a problem, but removing the following @OutputCache directive in
the LeftNavigation.ascx control fixed the problem:

<%@ OutputCache Duration="2592000" VaryByParam="none" Shared="True"
VaryByCustom="page" %>

I don't know why this caused the problem, since I had cleared the entire
browser cache, but getting rid of it fixed my problem, so that's enough to
make me happy for now.
--
Nathan Sokalski

http://www.nathansokalski.com/

"Sergey Poberezovskiy" <> wrote
in message news:7DA1840B-981D-4BC9-A987-...
> Nathan,
>
> I was wright - I use Master.Master to initilise the control tree -
> strangely
> enough I do not have comments explaining the reason (as I usually do).
> The code, however, is wrapped in a try catch, and if not succeeded, then
> called again from Init - again, not sure why - has been quite a few years
> now
> - but seems to be working ...
>
> Could you try to create a small project that consistently recreates the
> problem, and send it to - I will have a look at it
> for
> you
>
> "Nathan Sokalski" wrote:
>
>> Thanks. I was working on figuring out what's wrong, and although I
>> haven't
>> found an answer, I did find something that if I spend a few weeks pulling
>> my
>> hair out looking at, might get me a solution. I was looking at the
>> LoadControl method. The problem is, it seems very inefficient (if
>> possible)
>> to use it to solve my problem. No problem being late with the code, my
>> family was here over the weekend, so I was busy until now anyway. Hope to
>> hear from you soon!
>> --
>> Nathan Sokalski
>>
>> http://www.nathansokalski.com/
>>
>> "Sergey Poberezovskiy" <>
>> wrote
>> in message news:061004E9-E62E-4C5A-B9D1-...
>> > Sorry man - forgot again
>> >
>> > I will send myself a reminder email - so you can expect some code
>> > tomorrow
>> > if it is still required...
>> >
>> >
>> > "Nathan Sokalski" wrote:
>> >
>> >> Unfortunately, that code isn't helping. When I tried changing my
>> >> PreInit
>> >> to:
>> >>
>> >> Private Sub Page_PreInit(ByVal sender As Object, ByVal e As
>> >> System.EventArgs) Handles Me.PreInit
>> >> If Me.Master.Master Is Nothing Then Me.Master.SelectedNavigationID =
>> >> "menuConditionalValidator"
>> >> End Sub
>> >>
>> >> It gave me the same error I was getting before, since Me.Master.Master
>> >> Is
>> >> Nothing evaluates to True.
>> >>
>> >> I am using PreInit to set a property of a UserControl I created for
>> >> the
>> >> navigation on my site. If this property is not set, the navigation
>> >> hierarchy
>> >> will be collapsed and not have the current page highlighted. If you go
>> >> to
>> >> my
>> >> website, you can see this UserControl on the left side of all the
>> >> pages
>> >> (my
>> >> live site is still working, because I haven't tried to update it since
>> >> I
>> >> started having this problem when debugging it at home).
>> >> --
>> >> Nathan Sokalski
>> >>
>> >> http://www.nathansokalski.com/
>> >>
>> >> "Sergey Poberezovskiy" <>
>> >> wrote
>> >> in message news:527D721D-A86D-430C-B35B-...
>> >> > Nathan,
>> >> >
>> >> > I'm sorry I forgot to lookup the code for you - when I got back
>> >> > home, I
>> >> > got
>> >> > carried away with family stuff.
>> >> >
>> >> > From memory, to initiate MasterPage child control, I had to call on
>> >> > its
>> >> > Master property - this caused the whole control tree to load.
>> >> > Something
>> >> > like:
>> >> > If Me.Master.Master Is Nothing Then
>> >> > Me.Master.SelectedNavigationID = value
>> >> > End If
>> >> >
>> >> > Though it looks like a hack, but it does the job (if I remember
>> >> > correctly) -
>> >> > give it a shot. If you have a hierarchy of Master pages, you might
>> >> > need
>> >> > to
>> >> > do
>> >> > even more levels, something like:
>> >> > If Me.Master Is Nothing OrElse Me.Master.Master Is Nothing OrElse
>> >> > ...
>> >> >
>> >> > I use PreInit event to populate data controls without adding the
>> >> > data
>> >> > into
>> >> > ViewState - what is your reason?
>> >> >
>> >> >
>> >> > "Nathan Sokalski" wrote:
>> >> >
>> >> >> Thank you for your response, I look forward to seeing your code
>> >> >> (hopefully
>> >> >> it will help me solve the problem). The line that the error
>> >> >> actually
>> >> >> occurs
>> >> >> on if I debug is:
>> >> >>
>> >> >> Private Sub Page_PreInit(ByVal sender As Object, ByVal e As
>> >> >> System.EventArgs) Handles Me.PreInit
>> >> >> Me.Master.SelectedNavigationID = "menuConditionalValidator"
>> >> >> End Sub
>> >> >>
>> >> >> which is in the Content Page. However, I originally tried placing a
>> >> >> breakpoint on this line to see whether Me.Master was Nothing or
>> >> >> not,
>> >> >> but
>> >> >> it
>> >> >> was perfectly fine, so I then moved the breakpoint to the Set
>> >> >> method
>> >> >> of
>> >> >> the
>> >> >> SelectedNavigationID property in:
>> >> >>
>> >> >> Public Property SelectedNavigationID() As String
>> >> >> Get
>> >> >> Return Me.leftnavNavigation.SelectedNavigationID
>> >> >> End Get
>> >> >> Set(ByVal value As String)
>> >> >> Me.leftnavNavigation.SelectedNavigationID = value
>> >> >> End Set
>> >> >> End Property
>> >> >>
>> >> >> where I found out that the object that was actually Nothing was
>> >> >> Me.leftnavNavigation. I doubt that the problem is in
>> >> >> leftnavNavigation
>> >> >> (although who knows at this point), since it didn't give me any
>> >> >> problems
>> >> >> in
>> >> >> the project before (but neither did anything else) and I haven't
>> >> >> changed
>> >> >> anything, not to mention that it is Nothing at this point, so the
>> >> >> only
>> >> >> place
>> >> >> the problem could be is in initialization, and I'm guessing I would
>> >> >> get
>> >> >> some
>> >> >> other error if that was the problem (but I could be wrong). Anyway,
>> >> >> I
>> >> >> look
>> >> >> forward to seeing your code, and if you think seeing any of my code
>> >> >> will
>> >> >> help, just let me know (I just don't want to sent huge amounts of
>> >> >> code
>> >> >> that
>> >> >> won't help anybody, but I am willing to share any code I write with
>> >> >> anybody
>> >> >> who is interested). Thank you again for all your effort, it's good
>> >> >> to
>> >> >> know
>> >> >> there are people that really care about helping.
>> >> >> --
>> >> >> Nathan Sokalski
>> >> >>
>> >> >> http://www.nathansokalski.com/
>> >> >>
>> >> >> "Sergey Poberezovskiy"
>> >> >> <>
>> >> >> wrote
>> >> >> in message
>> >> >> news:B46F26A9-B59C-4BC7-837C-...
>> >> >> > Nathan,
>> >> >> >
>> >> >> > It looks like now the problem is in eftnavNavigation control (or
>> >> >> > its
>> >> >> > SelectedNavigationID) property.
>> >> >> > Try to put a breakpoint on the setter and see whether you can
>> >> >> > read a
>> >> >> > value
>> >> >> > from the SelectedNavigationID property - then you might be able
>> >> >> > to
>> >> >> > set
>> >> >> > it.
>> >> >> >
>> >> >> > I had similar problem trying to access Master page controls from
>> >> >> > the
>> >> >> > page
>> >> >> > on
>> >> >> > PreInit event, when not all child controls (including Master page
>> >> >> > control)
>> >> >> > are initialised. Unfortunately, I do not have the code handy - I
>> >> >> > will
>> >> >> > post
>> >> >> > it
>> >> >> > (if I can find it) in the next 8-10 hours.
>> >> >> >
>> >> >> > "Nathan Sokalski" wrote:
>> >> >> >
>> >> >> >> I tried that by changing my code from:
>> >> >> >>
>> >> >> >> Public Property SelectedNavigationID() As String
>> >> >> >> Get
>> >> >> >> Return Me.leftnavNavigation.SelectedNavigationID
>> >> >> >> End Get
>> >> >> >> Set(ByVal value As String)
>> >> >> >> Me.leftnavNavigation.SelectedNavigationID = value
>> >> >> >> End Set
>> >> >> >> End Property
>> >> >> >>
>> >> >> >> To:
>> >> >> >>
>> >> >> >> Public Property SelectedNavigationID() As String
>> >> >> >> Get
>> >> >> >> Me.EnsureChildControls()
>> >> >> >> Return Me.leftnavNavigation.SelectedNavigationID
>> >> >> >> End Get
>> >> >> >> Set(ByVal value As String)
>> >> >> >> Me.EnsureChildControls()
>> >> >> >> System.Diagnostics.Debug.WriteLine(IsNothing(Me.le ftnavNavigation))
>> >> >> >> Me.leftnavNavigation.SelectedNavigationID = value
>> >> >> >> End Set
>> >> >> >> End Property
>> >> >> >>
>> >> >> >> Not only does the Debug.WriteLine output the value True, but I
>> >> >> >> still
>> >> >> >> get
>> >> >> >> the
>> >> >> >> same error saying "Object reference not set to an instance of an
>> >> >> >> object.".
>> >> >> >> Unless I used the EnsureChildControls() method incorrectly here,
>> >> >> >> it
>> >> >> >> unfortunately did not solve the problem. Any other ideas?
>> >> >> >> Thanks.
>> >> >> >> --
>> >> >> >> Nathan Sokalski
>> >> >> >>
>> >> >> >> http://www.nathansokalski.com/
>> >> >> >>
>> >> >> >> "Sergey Poberezovskiy"
>> >> >> >> <>
>> >> >> >> wrote
>> >> >> >> in message
>> >> >> >> news:B1B794F2-9B52-4D60-8ED8-...
>> >> >> >> > Nathan,
>> >> >> >> >
>> >> >> >> > Take a look at the following link:
>> >> >> >> > http://msdn.microsoft.com/en-us/libr...dcontrols.aspx
>> >> >> >> >
>> >> >> >> > This looks like the solution to your problem.
>> >> >> >> >
>> >> >> >> > "Nathan Sokalski" wrote:
>> >> >> >> >
>> >> >> >> >> I have a Master page that contains a custom property, defined
>> >> >> >> >> as
>> >> >> >> >> follows:
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >> Public Property SelectedNavigationID() As String
>> >> >> >> >> Get
>> >> >> >> >> Return Me.leftnavNavigation.SelectedNavigationID
>> >> >> >> >> End Get
>> >> >> >> >> Set(ByVal value As String)
>> >> >> >> >> Me.leftnavNavigation.SelectedNavigationID = value
>> >> >> >> >> End Set
>> >> >> >> >> End Property
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >> As you can see, this property is used to set the value of a
>> >> >> >> >> property
>> >> >> >> >> of
>> >> >> >> >> one
>> >> >> >> >> of the Master page's Controls. I set the property from the
>> >> >> >> >> Content
>> >> >> >> >> page
>> >> >> >> >> as
>> >> >> >> >> follows:
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >> Private Sub Page_PreInit(ByVal sender As Object, ByVal e As
>> >> >> >> >> System.EventArgs) Handles Me.PreInit
>> >> >> >> >> Me.Master.SelectedNavigationID = "menuConditionalValidator"
>> >> >> >> >> End Sub
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >> The problem occurs in the Set method of the property defined
>> >> >> >> >> in
>> >> >> >> >> the
>> >> >> >> >> Master
>> >> >> >> >> page; it tells me that Me.leftnavNavigation has a value of
>> >> >> >> >> Nothing,
>> >> >> >> >> which
>> >> >> >> >> obviously prevents me from setting the property. I know that
>> >> >> >> >> I
>> >> >> >> >> am
>> >> >> >> >> missing
>> >> >> >> >> something simple, because this is almost exactly the same as
>> >> >> >> >> a
>> >> >> >> >> previous
>> >> >> >> >> version of the site I am recreating, which works perfectly.
>> >> >> >> >> What
>> >> >> >> >> could
>> >> >> >> >> be
>> >> >> >> >> causing the problem? Any help would be appreciated. Thanks.
>> >> >> >> >> --
>> >> >> >> >> Nathan Sokalski
>> >> >> >> >>
>> >> >> >> >> http://www.nathansokalski.com/
>> >> >> >> >>

 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      03-03-2010
On Mar 3, 4:06*pm, "Nathan Sokalski" <njsokal...@hotmail.com> wrote:
> Good (I mean great!) News! I finally found the problem! I don't know why it
> was causing a problem, but removing the following @OutputCache directive in
> the LeftNavigation.ascx control fixed the problem:
>
> <%@ OutputCache Duration="2592000" VaryByParam="none" Shared="True"
> VaryByCustom="page" %>
>
> I don't know why this caused the problem, since I had cleared the entire
> browser cache, but getting rid of it fixed my problem, so that's enough to
> make me happy for now.
> --
> Nathan Sokalski
> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>
> "Sergey Poberezovskiy" <SergeyPoberezovs...@discussions.microsoft.com> wrote
> in messagenews:7DA1840B-981D-4BC9-A987-...
>
>
>
> > Nathan,

>
> > I was wright - I use Master.Master to initilise the control tree -
> > strangely
> > enough I do not have comments explaining the reason (as I usually do).
> > The code, however, is wrapped in a try catch, and if not succeeded, then
> > called again from Init - again, not sure why - has been quite a few years
> > now
> > - but seems to be working ...

>
> > Could you try to create a small project that consistently recreates the
> > problem, and send it to se...@compros.com.au - I will have a look at it
> > for
> > you

>
> > "Nathan Sokalski" wrote:

>
> >> Thanks. I was working on figuring out what's wrong, and although I
> >> haven't
> >> found an answer, I did find something that if I spend a few weeks pulling
> >> my
> >> hair out looking at, might get me a solution. I was looking at the
> >> LoadControl method. The problem is, it seems very inefficient (if
> >> possible)
> >> to use it to solve my problem. No problem being late with the code, my
> >> family was here over the weekend, so I was busy until now anyway. Hope to
> >> hear from you soon!
> >> --
> >> Nathan Sokalski
> >> njsokal...@hotmail.com
> >>http://www.nathansokalski.com/

>
> >> "Sergey Poberezovskiy" <SergeyPoberezovs...@discussions.microsoft.com>
> >> wrote
> >> in messagenews:061004E9-E62E-4C5A-B9D1-...
> >> > Sorry man - forgot again

>
> >> > I will send myself a reminder email - so you can expect some code
> >> > tomorrow
> >> > if it is still required...

>
> >> > "Nathan Sokalski" wrote:

>
> >> >> Unfortunately, that code isn't helping. When I tried changing my
> >> >> PreInit
> >> >> to:

>
> >> >> Private Sub Page_PreInit(ByVal sender As Object, ByVal e As
> >> >> System.EventArgs) Handles Me.PreInit
> >> >> If Me.Master.Master Is Nothing Then Me.Master.SelectedNavigationID =
> >> >> "menuConditionalValidator"
> >> >> End Sub

>
> >> >> It gave me the same error I was getting before, since Me.Master.Master
> >> >> Is
> >> >> Nothing evaluates to True.

>
> >> >> I am using PreInit to set a property of a UserControl I created for
> >> >> the
> >> >> navigation on my site. If this property is not set, the navigation
> >> >> hierarchy
> >> >> will be collapsed and not have the current page highlighted. If you go
> >> >> to
> >> >> my
> >> >> website, you can see this UserControl on the left side of all the
> >> >> pages
> >> >> (my
> >> >> live site is still working, because I haven't tried to update it since
> >> >> I
> >> >> started having this problem when debugging it at home).
> >> >> --
> >> >> Nathan Sokalski
> >> >> njsokal...@hotmail.com
> >> >>http://www.nathansokalski.com/

>
> >> >> "Sergey Poberezovskiy" <SergeyPoberezovs...@discussions.microsoft.com>
> >> >> wrote
> >> >> in messagenews:527D721D-A86D-430C-B35B-....
> >> >> > Nathan,

>
> >> >> > I'm sorry I forgot to lookup the code for you - when I got back
> >> >> > home, I
> >> >> > got
> >> >> > carried away with family stuff.

>
> >> >> > From memory, to initiate MasterPage child control, I had to call on
> >> >> > its
> >> >> > Master property - this caused the whole control tree to load.
> >> >> > Something
> >> >> > like:
> >> >> > If Me.Master.Master Is Nothing Then
> >> >> > Me.Master.SelectedNavigationID = value
> >> >> > End If

>
> >> >> > Though it looks like a hack, but it does the job (if I remember
> >> >> > correctly) -
> >> >> > give it a shot. If you have a hierarchy of Master pages, you might
> >> >> > need
> >> >> > to
> >> >> > do
> >> >> > even more levels, something like:
> >> >> > If Me.Master Is Nothing OrElse Me.Master.Master Is Nothing OrElse
> >> >> > ...

>
> >> >> > I use PreInit event to populate data controls without adding the
> >> >> > data
> >> >> > into
> >> >> > ViewState - what is your reason?

>
> >> >> > "Nathan Sokalski" wrote:

>
> >> >> >> Thank you for your response, I look forward to seeing your code
> >> >> >> (hopefully
> >> >> >> it will help me solve the problem). The line that the error
> >> >> >> actually
> >> >> >> occurs
> >> >> >> on if I debug is:

>
> >> >> >> Private Sub Page_PreInit(ByVal sender As Object, ByVal e As
> >> >> >> System.EventArgs) Handles Me.PreInit
> >> >> >> Me.Master.SelectedNavigationID = "menuConditionalValidator"
> >> >> >> End Sub

>
> >> >> >> which is in the Content Page. However, I originally tried placing a
> >> >> >> breakpoint on this line to see whether Me.Master was Nothing or
> >> >> >> not,
> >> >> >> but
> >> >> >> it
> >> >> >> was perfectly fine, so I then moved the breakpoint to the Set
> >> >> >> method
> >> >> >> of
> >> >> >> the
> >> >> >> SelectedNavigationID property in:

>
> >> >> >> Public Property SelectedNavigationID() As String
> >> >> >> Get
> >> >> >> Return Me.leftnavNavigation.SelectedNavigationID
> >> >> >> End Get
> >> >> >> Set(ByVal value As String)
> >> >> >> Me.leftnavNavigation.SelectedNavigationID = value
> >> >> >> End Set
> >> >> >> End Property

>
> >> >> >> where I found out that the object that was actually Nothing was
> >> >> >> Me.leftnavNavigation. I doubt that the problem is in
> >> >> >> leftnavNavigation
> >> >> >> (although who knows at this point), since it didn't give me any
> >> >> >> problems
> >> >> >> in
> >> >> >> the project before (but neither did anything else) and I haven't
> >> >> >> changed
> >> >> >> anything, not to mention that it is Nothing at this point, so the
> >> >> >> only
> >> >> >> place
> >> >> >> the problem could be is in initialization, and I'm guessing I would
> >> >> >> get
> >> >> >> some
> >> >> >> other error if that was the problem (but I could be wrong). Anyway,
> >> >> >> I
> >> >> >> look
> >> >> >> forward to seeing your code, and if you think seeing any of my code
> >> >> >> will
> >> >> >> help, just let me know (I just don't want to sent huge amounts of
> >> >> >> code
> >> >> >> that
> >> >> >> won't help anybody, but I am willing to share any code I write with
> >> >> >> anybody
> >> >> >> who is interested). Thank you again for all your effort, it's good
> >> >> >> to
> >> >> >> know
> >> >> >> there are people that really care about helping.
> >> >> >> --
> >> >> >> Nathan Sokalski
> >> >> >> njsokal...@hotmail.com
> >> >> >>http://www.nathansokalski.com/

>
> >> >> >> "Sergey Poberezovskiy"
> >> >> >> <SergeyPoberezovs...@discussions.microsoft.com>
> >> >> >> wrote
> >> >> >> in message
> >> >> >>news:B46F26A9-B59C-4BC7-837C-...
> >> >> >> > Nathan,

>
> >> >> >> > It looks like now the problem is in eftnavNavigation control (or
> >> >> >> > its
> >> >> >> > SelectedNavigationID) property.
> >> >> >> > Try to put a breakpoint on the setter and see whether you can
> >> >> >> > read a
> >> >> >> > value
> >> >> >> > from the SelectedNavigationID property - then you might be able
> >> >> >> > to
> >> >> >> > set
> >> >> >> > it.

>
> >> >> >> > I had similar problem trying to access Master page controls from
> >> >> >> > the
> >> >> >> > page
> >> >> >> > on
> >> >> >> > PreInit event, when not all child controls (including Master page
> >> >> >> > control)
> >> >> >> > are initialised. Unfortunately, I do not have the code handy - I
> >> >> >> > will
> >> >> >> > post
> >> >> >> > it
> >> >> >> > (if I can find it) in the next 8-10 hours.

>
> >> >> >> > "Nathan Sokalski" wrote:

>
> >> >> >> >> I tried that by changing my code from:

>
> >> >> >> >> Public Property SelectedNavigationID() As String
> >> >> >> >> Get
> >> >> >> >> Return Me.leftnavNavigation.SelectedNavigationID
> >> >> >> >> End Get
> >> >> >> >> Set(ByVal value As String)
> >> >> >> >> Me.leftnavNavigation.SelectedNavigationID = value
> >> >> >> >> End Set
> >> >> >> >> End Property

>
> >> >> >> >> To:

>
> >> >> >> >> Public Property SelectedNavigationID() As String
> >> >> >> >> Get
> >> >> >> >> Me.EnsureChildControls()
> >> >> >> >> Return Me.leftnavNavigation.SelectedNavigationID
> >> >> >> >> End Get
> >> >> >> >> Set(ByVal value As String)
> >> >> >> >> Me.EnsureChildControls()
> >> >> >> >> System.Diagnostics.Debug.WriteLine(IsNothing(Me.le ftnavNavigation))
> >> >> >> >> Me.leftnavNavigation.SelectedNavigationID = value
> >> >> >> >> End Set
> >> >> >> >> End Property

>
> >> >> >> >> Not only does the Debug.WriteLine output the value True, but I
> >> >> >> >> still
> >> >> >> >> get
> >> >> >> >> the
> >> >> >> >> same error saying "Object reference not set to an instance of an
> >> >> >> >> object.".
> >> >> >> >> Unless I used the EnsureChildControls() method incorrectly here,
> >> >> >> >> it
> >> >> >> >> unfortunately did not solve the problem. Any other ideas?
> >> >> >> >> Thanks.
> >> >> >> >> --
> >> >> >> >> Nathan Sokalski
> >> >> >> >> njsokal...@hotmail.com
> >> >> >> >>http://www.nathansokalski.com/

>
> >> >> >> >> "Sergey Poberezovskiy"
> >> >> >> >> <SergeyPoberezovs...@discussions.microsoft.com>
> >> >> >> >> wrote
> >> >> >> >> in message
> >> >> >> >>news:B1B794F2-9B52-4D60-8ED8-...
> >> >> >> >> > Nathan,

>
> >> >> >> >> > Take a look at the following link:
> >> >> >> >> >http://msdn.microsoft.com/en-us/libr...ontrol.ensurec...

>
> >> >> >> >> > This looks like the solution to your problem.

>
> >> >> >> >> > "Nathan Sokalski" wrote:

>
> >> >> >> >> >> I have a Master page that contains a custom property, defined
> >> >> >> >> >> as
> >> >> >> >> >> follows:

>
> >> >> >> >> >> Public Property SelectedNavigationID() As String

>
> ...
>
> read more »


OutputCache is cached in ASP.NET cache on server. You set 30 days to
cache the control and that's why it was not updated.
 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      03-04-2010
So the ASP.NET cache is different from the browser cache? Does that mean
that if I put the directive back in 30 days from now (or once it was gone
from the ASP.NET cache) it would be ok? Is there a way to clear the ASP.NET
cache? My experience with ASP.NET cache is somewhat limited (I understand
how the browser does caching, but I am unfamiliar with what ASP.NET can do
as far as caching). I would obviously like to apply any applicable features
to this control, since it looks the same every time you visit the page, but
I'm obviously not going to add a directive that's going to prevent my site
from working. Thanks.
--
Nathan Sokalski

http://www.nathansokalski.com/

"Alexey Smirnov" <> wrote in message
news:5ce5c71e-7453-407a-950b-...
> On Mar 3, 4:06 pm, "Nathan Sokalski" <njsokal...@hotmail.com> wrote:
>> Good (I mean great!) News! I finally found the problem! I don't know why
>> it
>> was causing a problem, but removing the following @OutputCache directive
>> in
>> the LeftNavigation.ascx control fixed the problem:
>>
>> <%@ OutputCache Duration="2592000" VaryByParam="none" Shared="True"
>> VaryByCustom="page" %>
>>
>> I don't know why this caused the problem, since I had cleared the entire
>> browser cache, but getting rid of it fixed my problem, so that's enough
>> to
>> make me happy for now.
>> --
>> Nathan Sokalski
>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>>
>> "Sergey Poberezovskiy" <SergeyPoberezovs...@discussions.microsoft.com>
>> wrote
>> in messagenews:7DA1840B-981D-4BC9-A987-...
>>
>>
>>
>> > Nathan,

>>
>> > I was wright - I use Master.Master to initilise the control tree -
>> > strangely
>> > enough I do not have comments explaining the reason (as I usually do).
>> > The code, however, is wrapped in a try catch, and if not succeeded,
>> > then
>> > called again from Init - again, not sure why - has been quite a few
>> > years
>> > now
>> > - but seems to be working ...

>>
>> > Could you try to create a small project that consistently recreates the
>> > problem, and send it to se...@compros.com.au - I will have a look at it
>> > for
>> > you

>>
>> > "Nathan Sokalski" wrote:

>>
>> >> Thanks. I was working on figuring out what's wrong, and although I
>> >> haven't
>> >> found an answer, I did find something that if I spend a few weeks
>> >> pulling
>> >> my
>> >> hair out looking at, might get me a solution. I was looking at the
>> >> LoadControl method. The problem is, it seems very inefficient (if
>> >> possible)
>> >> to use it to solve my problem. No problem being late with the code, my
>> >> family was here over the weekend, so I was busy until now anyway. Hope
>> >> to
>> >> hear from you soon!
>> >> --
>> >> Nathan Sokalski
>> >> njsokal...@hotmail.com
>> >>http://www.nathansokalski.com/

>>
>> >> "Sergey Poberezovskiy" <SergeyPoberezovs...@discussions.microsoft.com>
>> >> wrote
>> >> in messagenews:061004E9-E62E-4C5A-B9D1-...
>> >> > Sorry man - forgot again

>>
>> >> > I will send myself a reminder email - so you can expect some code
>> >> > tomorrow
>> >> > if it is still required...

>>
>> >> > "Nathan Sokalski" wrote:

>>
>> >> >> Unfortunately, that code isn't helping. When I tried changing my
>> >> >> PreInit
>> >> >> to:

>>
>> >> >> Private Sub Page_PreInit(ByVal sender As Object, ByVal e As
>> >> >> System.EventArgs) Handles Me.PreInit
>> >> >> If Me.Master.Master Is Nothing Then Me.Master.SelectedNavigationID
>> >> >> =
>> >> >> "menuConditionalValidator"
>> >> >> End Sub

>>
>> >> >> It gave me the same error I was getting before, since
>> >> >> Me.Master.Master
>> >> >> Is
>> >> >> Nothing evaluates to True.

>>
>> >> >> I am using PreInit to set a property of a UserControl I created for
>> >> >> the
>> >> >> navigation on my site. If this property is not set, the navigation
>> >> >> hierarchy
>> >> >> will be collapsed and not have the current page highlighted. If you
>> >> >> go
>> >> >> to
>> >> >> my
>> >> >> website, you can see this UserControl on the left side of all the
>> >> >> pages
>> >> >> (my
>> >> >> live site is still working, because I haven't tried to update it
>> >> >> since
>> >> >> I
>> >> >> started having this problem when debugging it at home).
>> >> >> --
>> >> >> Nathan Sokalski
>> >> >> njsokal...@hotmail.com
>> >> >>http://www.nathansokalski.com/

>>
>> >> >> "Sergey Poberezovskiy"
>> >> >> <SergeyPoberezovs...@discussions.microsoft.com>
>> >> >> wrote
>> >> >> in
>> >> >> messagenews:527D721D-A86D-430C-B35B-...
>> >> >> > Nathan,

>>
>> >> >> > I'm sorry I forgot to lookup the code for you - when I got back
>> >> >> > home, I
>> >> >> > got
>> >> >> > carried away with family stuff.

>>
>> >> >> > From memory, to initiate MasterPage child control, I had to call
>> >> >> > on
>> >> >> > its
>> >> >> > Master property - this caused the whole control tree to load.
>> >> >> > Something
>> >> >> > like:
>> >> >> > If Me.Master.Master Is Nothing Then
>> >> >> > Me.Master.SelectedNavigationID = value
>> >> >> > End If

>>
>> >> >> > Though it looks like a hack, but it does the job (if I remember
>> >> >> > correctly) -
>> >> >> > give it a shot. If you have a hierarchy of Master pages, you
>> >> >> > might
>> >> >> > need
>> >> >> > to
>> >> >> > do
>> >> >> > even more levels, something like:
>> >> >> > If Me.Master Is Nothing OrElse Me.Master.Master Is Nothing OrElse
>> >> >> > ...

>>
>> >> >> > I use PreInit event to populate data controls without adding the
>> >> >> > data
>> >> >> > into
>> >> >> > ViewState - what is your reason?

>>
>> >> >> > "Nathan Sokalski" wrote:

>>
>> >> >> >> Thank you for your response, I look forward to seeing your code
>> >> >> >> (hopefully
>> >> >> >> it will help me solve the problem). The line that the error
>> >> >> >> actually
>> >> >> >> occurs
>> >> >> >> on if I debug is:

>>
>> >> >> >> Private Sub Page_PreInit(ByVal sender As Object, ByVal e As
>> >> >> >> System.EventArgs) Handles Me.PreInit
>> >> >> >> Me.Master.SelectedNavigationID = "menuConditionalValidator"
>> >> >> >> End Sub

>>
>> >> >> >> which is in the Content Page. However, I originally tried
>> >> >> >> placing a
>> >> >> >> breakpoint on this line to see whether Me.Master was Nothing or
>> >> >> >> not,
>> >> >> >> but
>> >> >> >> it
>> >> >> >> was perfectly fine, so I then moved the breakpoint to the Set
>> >> >> >> method
>> >> >> >> of
>> >> >> >> the
>> >> >> >> SelectedNavigationID property in:

>>
>> >> >> >> Public Property SelectedNavigationID() As String
>> >> >> >> Get
>> >> >> >> Return Me.leftnavNavigation.SelectedNavigationID
>> >> >> >> End Get
>> >> >> >> Set(ByVal value As String)
>> >> >> >> Me.leftnavNavigation.SelectedNavigationID = value
>> >> >> >> End Set
>> >> >> >> End Property

>>
>> >> >> >> where I found out that the object that was actually Nothing was
>> >> >> >> Me.leftnavNavigation. I doubt that the problem is in
>> >> >> >> leftnavNavigation
>> >> >> >> (although who knows at this point), since it didn't give me any
>> >> >> >> problems
>> >> >> >> in
>> >> >> >> the project before (but neither did anything else) and I haven't
>> >> >> >> changed
>> >> >> >> anything, not to mention that it is Nothing at this point, so
>> >> >> >> the
>> >> >> >> only
>> >> >> >> place
>> >> >> >> the problem could be is in initialization, and I'm guessing I
>> >> >> >> would
>> >> >> >> get
>> >> >> >> some
>> >> >> >> other error if that was the problem (but I could be wrong).
>> >> >> >> Anyway,
>> >> >> >> I
>> >> >> >> look
>> >> >> >> forward to seeing your code, and if you think seeing any of my
>> >> >> >> code
>> >> >> >> will
>> >> >> >> help, just let me know (I just don't want to sent huge amounts
>> >> >> >> of
>> >> >> >> code
>> >> >> >> that
>> >> >> >> won't help anybody, but I am willing to share any code I write
>> >> >> >> with
>> >> >> >> anybody
>> >> >> >> who is interested). Thank you again for all your effort, it's
>> >> >> >> good
>> >> >> >> to
>> >> >> >> know
>> >> >> >> there are people that really care about helping.
>> >> >> >> --
>> >> >> >> Nathan Sokalski
>> >> >> >> njsokal...@hotmail.com
>> >> >> >>http://www.nathansokalski.com/

>>
>> >> >> >> "Sergey Poberezovskiy"
>> >> >> >> <SergeyPoberezovs...@discussions.microsoft.com>
>> >> >> >> wrote
>> >> >> >> in message
>> >> >> >>news:B46F26A9-B59C-4BC7-837C-...
>> >> >> >> > Nathan,

>>
>> >> >> >> > It looks like now the problem is in eftnavNavigation control
>> >> >> >> > (or
>> >> >> >> > its
>> >> >> >> > SelectedNavigationID) property.
>> >> >> >> > Try to put a breakpoint on the setter and see whether you can
>> >> >> >> > read a
>> >> >> >> > value
>> >> >> >> > from the SelectedNavigationID property - then you might be
>> >> >> >> > able
>> >> >> >> > to
>> >> >> >> > set
>> >> >> >> > it.

>>
>> >> >> >> > I had similar problem trying to access Master page controls
>> >> >> >> > from
>> >> >> >> > the
>> >> >> >> > page
>> >> >> >> > on
>> >> >> >> > PreInit event, when not all child controls (including Master
>> >> >> >> > page
>> >> >> >> > control)
>> >> >> >> > are initialised. Unfortunately, I do not have the code handy -
>> >> >> >> > I
>> >> >> >> > will
>> >> >> >> > post
>> >> >> >> > it
>> >> >> >> > (if I can find it) in the next 8-10 hours.

>>
>> >> >> >> > "Nathan Sokalski" wrote:

>>
>> >> >> >> >> I tried that by changing my code from:

>>
>> >> >> >> >> Public Property SelectedNavigationID() As String
>> >> >> >> >> Get
>> >> >> >> >> Return Me.leftnavNavigation.SelectedNavigationID
>> >> >> >> >> End Get
>> >> >> >> >> Set(ByVal value As String)
>> >> >> >> >> Me.leftnavNavigation.SelectedNavigationID = value
>> >> >> >> >> End Set
>> >> >> >> >> End Property

>>
>> >> >> >> >> To:

>>
>> >> >> >> >> Public Property SelectedNavigationID() As String
>> >> >> >> >> Get
>> >> >> >> >> Me.EnsureChildControls()
>> >> >> >> >> Return Me.leftnavNavigation.SelectedNavigationID
>> >> >> >> >> End Get
>> >> >> >> >> Set(ByVal value As String)
>> >> >> >> >> Me.EnsureChildControls()
>> >> >> >> >> System.Diagnostics.Debug.WriteLine(IsNothing(Me.le ftnavNavigation))
>> >> >> >> >> Me.leftnavNavigation.SelectedNavigationID = value
>> >> >> >> >> End Set
>> >> >> >> >> End Property

>>
>> >> >> >> >> Not only does the Debug.WriteLine output the value True, but
>> >> >> >> >> I
>> >> >> >> >> still
>> >> >> >> >> get
>> >> >> >> >> the
>> >> >> >> >> same error saying "Object reference not set to an instance of
>> >> >> >> >> an
>> >> >> >> >> object.".
>> >> >> >> >> Unless I used the EnsureChildControls() method incorrectly
>> >> >> >> >> here,
>> >> >> >> >> it
>> >> >> >> >> unfortunately did not solve the problem. Any other ideas?
>> >> >> >> >> Thanks.
>> >> >> >> >> --
>> >> >> >> >> Nathan Sokalski
>> >> >> >> >> njsokal...@hotmail.com
>> >> >> >> >>http://www.nathansokalski.com/

>>
>> >> >> >> >> "Sergey Poberezovskiy"
>> >> >> >> >> <SergeyPoberezovs...@discussions.microsoft.com>
>> >> >> >> >> wrote
>> >> >> >> >> in message
>> >> >> >> >>news:B1B794F2-9B52-4D60-8ED8-...
>> >> >> >> >> > Nathan,

>>
>> >> >> >> >> > Take a look at the following link:
>> >> >> >> >> >http://msdn.microsoft.com/en-us/libr...ontrol.ensurec...

>>
>> >> >> >> >> > This looks like the solution to your problem.

>>
>> >> >> >> >> > "Nathan Sokalski" wrote:

>>
>> >> >> >> >> >> I have a Master page that contains a custom property,
>> >> >> >> >> >> defined
>> >> >> >> >> >> as
>> >> >> >> >> >> follows:

>>
>> >> >> >> >> >> Public Property SelectedNavigationID() As String

>>
>> ...
>>
>> read more »

>
> OutputCache is cached in ASP.NET cache on server. You set 30 days to
> cache the control and that's why it was not updated.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Access Master Page Controls from page.aspx doesn't inherit from master SerpentKiss2010 ASP .Net 0 04-06-2011 02:46 PM
Setting master page properties from custom base page William Youngman ASP .Net 3 04-02-2007 02:46 PM
Can a master page be built from another master page Zeba ASP .Net 1 02-22-2007 10:55 AM
setting the text value of a control on the master page, from a content page Aussie Rules ASP .Net 5 07-25-2006 01:32 AM
Setting the Page Title using local resources for a content page in a master page Laith Zraikat ASP .Net 3 07-06-2006 01:23 AM



Advertisments
 



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 46 47 48 49 50 51 52 53 54 55 56 57