Results 1 to 21 of 21

Thread: Using Javascript and Masterpages

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Using Javascript and Masterpages

    I have a situation where I'm using a single Masterpage and two Content Pages. The Master page basically contains a menu built using an HTML Table. The one Content Page contains the marjority of my site content. The way the menu works is that when user selects a menu item, a javascript function executes that evaulates which menu item was selected.

    Now, this is where I'm not sure what to do next. Should I load the next Content Page in this javascript function or somewhere in the CodeBehind of the Content Page? I'm trying to find examples where I can load a page using Javascript but not having any luck. Can someone tell me how this is done?

    Thanks,
    Blake

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Using Javascript and Masterpages

    I think this question will get a better response in the ASP.NET section, so I've moved it.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Using Javascript and Masterpages

    Thanks!
    Blake

  4. #4
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Using Javascript and Masterpages

    I'm having a hard time grasp on what you are trying to do.Do you want a menu on all pages?Then you should do everything in a master page.Do you want a menu that interacts somehow differently in any page?I believe there would be problems because you will have to reference the menu of the master page through javascript and since it's the masterpage there are some trick you must do in order to find an item of it with js through a content page.
    Can you explain better?
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  5. #5
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Using Javascript and Masterpages

    Hello,

    Is it possible that you can show the code that you are currently using?

    As sap has said, simply navigating to the next page should be all that is required, there should be no need for JavaScript/jQuery to get involved at all. Unless you are trying to control everything on the client side, without the need to post back to the server, but if you are doing that, it does beg the question why you are using ASP.Net at all.

    Gary

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Using Javascript and Masterpages

    Gary,

    This website basically consists of 1 page. I'm using alot of Javascript to control the content, however, when the page loads in the browser, it takes along time and the way it looks is how it should look when the user is interacting with the site.

    I tried using a MasterPage approach to see if that would solve the problem and that's where I'm at now.

    Anyway, I've attached a screenshot of the site. When the page first loads, it is suppose to show an Image only, however, if you look at the screenshot, these sections are expandable. They are controlled with Javascript. But, when the page loads, these sections are expanded and they shouldn't be. Only the Image should be seen.

    Thanks,
    Blake

  7. #7
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Using Javascript and Masterpages

    The sections are expanded.So what does this has to do with the menu?
    Is the whole page something like a menu?Sessions are menus?
    Of course you should provide all the markup page code + jscript or we are wasting our time and yours.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Using Javascript and Masterpages

    Sapator,

    When you first go to my page, the sections are opened and they shouldn't be. I've programmed them to NOT be open when the page loads but I don't know why it's expanding them. I've attached the page that contains all the markup and javascript. Please keep in mind that I am pretty new to Javascript programming.
    Blake

  9. #9
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Using Javascript and Masterpages

    I get nothing without CSS file but it seems that the sections are hidden or display=none as you specify them.Are you using a master page?I think that is where the problem lies.
    Anyhow that seems a lot of work.Have you tried doing something with Jquery?
    Last edited by sapator; Feb 15th, 2012 at 08:18 PM.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Using Javascript and Masterpages

    Dude...I'm just trying to learn Javascript. I've that JQuery is Microsoft's version of Javascript. What's the advantage?
    Blake

  11. #11
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Using Javascript and Masterpages

    It's more compact coding.Anyhow since you started it that way try doing everything in a non master page and see if that works.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Using Javascript and Masterpages

    The page you see in www.blakemckenna.com is without using a MasterPage.
    Blake

  13. #13
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Using Javascript and Masterpages

    Quote Originally Posted by blakemckenna View Post
    Dude...I'm just trying to learn Javascript. I've that JQuery is Microsoft's version of Javascript. What's the advantage?
    Nope - not even close.

    jQuery is just a Javascript library of functions that makes DOM manipulation effortless.

    If you never did DOM manipulation before with straight JS you wouldn't really understand why using jQuery makes it easier!

    I started with jQuery about a year ago - but had to learn JS old-school-wise before any of it made sense!

    MS doesn't own jQuery - it's one of the first non-MS platforms that they have embraced - because it is that cool!

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Using Javascript and Masterpages

    Does anyone have any idea as to the problem in post #6?

    Thanks,
    Blake

  15. #15
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Using Javascript and Masterpages

    I just visited your site - got a FOUC (flash of unrendered content) that seemed like your menu - but then that disappeared.

    What is your problem in #6??

    Use Firefox - download FIREBUG to debug your js code - makes life much easier

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  16. #16

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Using Javascript and Masterpages

    That flash you saw is the problem. That flash of content should not show when the site loads. When the site initially loads, it displays an image of me. Then, when you click a menu link, it will display a collapsible frame. That's how it is suppose to work.
    Blake

  17. #17
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Using Javascript and Masterpages

    Hey, are you by any chance using firefox and NoScript add on?You possibly blocking javascript somehow because when i go to your page the tables are hidden.
    Edit:I don' see a flash but my internet line is faster than 200 lines of yours :P
    Last edited by sapator; Feb 15th, 2012 at 08:55 PM.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  18. #18
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Using Javascript and Masterpages

    Aha.Now i get it.I had to use iexplorer that is the slowest piece of trash in the universe.
    Ye well you are creating the controls on the page and then you are hiding them.So yes there is a problem here.How about trying using <body onprerender> instead of onload.Not sure but have a go
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  19. #19

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Using Javascript and Masterpages

    That didn't work...no change!
    Blake

  20. #20
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Using Javascript and Masterpages

    Then how about starting with all the controls hidden by CSS?What's the use of javascript if you want to hide the controls in the first place?Use CSS.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  21. #21
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Using Javascript and Masterpages

    Hello,

    The reason to use a Master Page or not shouldn't be driven by whether a page is taking a long time to load or not. If it is taking a long time to load, then you need to find out where the bottle neck it.

    You can do this in a number of ways, both on the client and the server, to see what is taking a long time. I would suggest you look at YSlow on the client, and enabling Trace on the server.

    This should give you somewhere to start.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width