Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 7 of 7

Thread: Anyone know how to do this? CSS/Javascript

  1. #1
    ssgumby is offline Senior Member
    Join Date
    Feb 2009
    Posts
    683

    Default Anyone know how to do this? CSS/Javascript

    Here is the thing, I have tabs across the top of my pages and I want to change the css class when it is clicked.

    Example :
    Code:
      <li class="homeNavTab" id="homeNavTab"><a href="default.aspx">Home</a>
    
      </li> 
      <li class="fooNavTab" id="fooNavTab"><a href="foo.aspx">Foo</a>
    
      </li>
    When Home is clicked i'd like to change the class from homeNavTab to homeNavTabOn. This won't work with an onclick as once that returns it loads the page and resets the class again.

    Any ideas on ways to accomplish this?

  2. #2
    ssgumby is offline Senior Member
    Join Date
    Feb 2009
    Posts
    683

    Default

    Is there a way at getting at a skin token in javascript in 9.x? I have a new skin token in the SkinBase class

    In 8.0.1.2 this worked
    Code:
    element.setAttribute("className", '(!NAVCLASS!)');
    but no longer works in 9.x

    Ive tried this to no avail

    Code:
    element.setAttribute("className", '<asp:Literal ID="NAVCLASS" runat="server" Text="" />');
    For 9.x I get The ID 'NAVCLASS' is already used by another control. Im calling this javascript on an onload event

  3. #3
    travisalmand is offline Junior Member
    Join Date
    Mar 2010
    Posts
    24

    Default

    For your first question you will need to prevent the link from completing its normal task, which is to load the page linked. In javascript you would do this with:

    return false;

    This should be the last thing in the onclick event or it will prevent anything else listed after it from firing.

    Keep in mind that this will break your link. If you didn't want it to link to another page but have it there for someone to click to get an action on the current page then that should work just fine.

    As for your second question, tokens are handled differently in the lastest version:

    http://manual.aspdotnetstorefront.co...in-tokens.aspx

    But I'm not sure if you can use the skin tokens from within Javascript code. I suppose you could but I haven't tried it.

  4. #4
    ssgumby is offline Senior Member
    Join Date
    Feb 2009
    Posts
    683

    Default

    In SkinBase.cs does this method never get called anymore?

    private string ReplaceTokens(String s)

    I added a new token here but debugging I never see this method being called.

  5. #5
    davlun is offline Member
    Join Date
    Apr 2010
    Posts
    36

    Default

    Using a javascript library, like jquery for example you could do the following:
    1) select the elements you want to update using the $ function in jquery
    2) reset the standard click event with your css style change

    I am not even close to getting my menu the way I want as far as the data out of the system yet, but I think you should be able to do this via jquery after the page loads.

    David

  6. #6
    akeller is offline Member
    Join Date
    Dec 2008
    Posts
    78

    Default

    @davlun or anyone

    I am trying to get jquery to work inside my master page and I can't seem to get it. I would like to include the js and css files I need in the master page and use them ON the master page as well as child pages. I have tried the resolveUrl, Script Manager, I simply cannot get it to work.

    Let me know how you included the files in your template.master if you would.

    Thanks

  7. #7
    davlun is offline Member
    Join Date
    Apr 2010
    Posts
    36

    Default

    I am not that far yet, still working on figuring out how things are put together. However, in general, you should just need to include the js files you need in your master page, in the head.

    Then set on onload event handler, kind of like they talk about here: http://docs.jquery.com/Tutorials:Int...29.ready%28%29