-
Feb 13th, 2012, 05:41 PM
#1
Thread Starter
PowerPoster
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,
-
Feb 13th, 2012, 08:05 PM
#2
Re: Using Javascript and Masterpages
I think this question will get a better response in the ASP.NET section, so I've moved it.
-
Feb 13th, 2012, 08:24 PM
#3
Thread Starter
PowerPoster
Re: Using Javascript and Masterpages
-
Feb 13th, 2012, 10:23 PM
#4
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?
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Feb 14th, 2012, 07:42 AM
#5
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
-
Feb 14th, 2012, 01:23 PM
#6
Thread Starter
PowerPoster
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,
-
Feb 14th, 2012, 08:28 PM
#7
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.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Feb 15th, 2012, 03:17 PM
#8
Thread Starter
PowerPoster
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.
-
Feb 15th, 2012, 08:08 PM
#9
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.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Feb 15th, 2012, 08:10 PM
#10
Thread Starter
PowerPoster
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?
-
Feb 15th, 2012, 08:20 PM
#11
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.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Feb 15th, 2012, 08:26 PM
#12
Thread Starter
PowerPoster
Re: Using Javascript and Masterpages
The page you see in www.blakemckenna.com is without using a MasterPage.
-
Feb 15th, 2012, 08:31 PM
#13
Re: Using Javascript and Masterpages
Originally Posted by blakemckenna
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!
-
Feb 15th, 2012, 08:34 PM
#14
Thread Starter
PowerPoster
Re: Using Javascript and Masterpages
Does anyone have any idea as to the problem in post #6?
Thanks,
-
Feb 15th, 2012, 08:38 PM
#15
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
-
Feb 15th, 2012, 08:48 PM
#16
Thread Starter
PowerPoster
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.
-
Feb 15th, 2012, 08:48 PM
#17
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.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Feb 15th, 2012, 08:55 PM
#18
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
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Feb 15th, 2012, 09:01 PM
#19
Thread Starter
PowerPoster
Re: Using Javascript and Masterpages
That didn't work...no change!
-
Feb 15th, 2012, 09:04 PM
#20
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.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Feb 16th, 2012, 02:09 PM
#21
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|