> What I want to know is what is the best approach to change these
> attributes based on the current content page. Should I be changing the
> attribute in the pre-render event using HTMLTextWriter or would some kind
> of client-side script work better here?
No need either for HTMLTextWriter or client-side script.
1) Set all of the menu item attributes to 'select' by default
2) Declare a property in the MasterPage's class
3) When the content page loads, make it set the value of the MasterPage
variable
4) When the MasterPage loads, interrogate the value of the MasterPage
variable and set the appropriate menu item attribute to 'current'
http://aspnet.4guysfromrolla.com/articles/013107-1.aspx

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
John - 14 Dec 2007 22:25 GMT
Perfect. Many thanks Mark, I was hoping there would be an easier solution
like this.
Best regards
John
>> What I want to know is what is the best approach to change these
>> attributes based on the current content page. Should I be changing the
[quoted text clipped - 14 lines]
>
> http://aspnet.4guysfromrolla.com/articles/013107-1.aspx
John - 17 Dec 2007 15:03 GMT
Hello Mark,
I've got the property declared in the MasterPage class, but can you give me
hint on how to set the various <ul> tags' attributes. I'm giving them
unique IDs so can I reference them directly in some way or do I have to walk
through the DOM checking for each one (I'm guessing not)?
Thanks
John
>> What I want to know is what is the best approach to change these
>> attributes based on the current content page. Should I be changing the
[quoted text clipped - 14 lines]
>
> http://aspnet.4guysfromrolla.com/articles/013107-1.aspx
Mark Rae [MVP] - 17 Dec 2007 15:24 GMT
>>> What I want to know is what is the best approach to change these
>>> attributes based on the current content page. Should I be changing the
[quoted text clipped - 19 lines]
> unique IDs so can I reference them directly in some way or do I have to
> walk through the DOM checking for each one (I'm guessing not)?
This is explained in the 4Guys article.
Alternatively, you can use FindControl which achieves the same effect,
though purists would no doubt say that it's not very OOP... ;-)
E.g. to set the text in a TextBox control on the MasterPage from the content
page, you could do something like:
((TextBox)Master.FindControl("MyTextBox")).Text = "Hello";

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
John - 17 Dec 2007 16:09 GMT
Hi Mark,
Thanks for this. I did read the article, which was very useful, but from my
first reading this only applied to server controls (also the FindControl
method?).
Does this also work for plain old HTML tags as well?
Apologies if I'm being slow on this......
Best regards
John
>>>> What I want to know is what is the best approach to change these
>>>> attributes based on the current content page. Should I be changing the
[quoted text clipped - 29 lines]
>
> ((TextBox)Master.FindControl("MyTextBox")).Text = "Hello";
Mark Rae [MVP] - 17 Dec 2007 16:14 GMT
>> ((TextBox)Master.FindControl("MyTextBox")).Text = "Hello";
>
[quoted text clipped - 3 lines]
>
> Does this also work for plain old HTML tags as well?
Yep - just give them an ID and mark them runat="server"

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
John - 17 Dec 2007 17:23 GMT
Great. Thanks very much for your help Mark.
best regards
John
>>> ((TextBox)Master.FindControl("MyTextBox")).Text = "Hello";
>>
[quoted text clipped - 5 lines]
>
> Yep - just give them an ID and mark them runat="server"