Main Page | Report this Page
.NET DotNet Forum Index  »  ASP.NET Forum  »  MVC, nested masterpage and Javascript...
Page 1 of 1    

MVC, nested masterpage and Javascript...

Author Message
Tommy Jakobsen...
Posted: Sat Sep 13, 2008 12:47 pm
Guest
Hi.

Is there a problem when trying to use Javascript on a nested masterpage?

On my masterpage, i've got this in the <head>:
<asp:ContentPlaceHolder ID="HeadContent" runat="server" />

And on the nested masterpage:
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<asp:ContentPlaceHolder ID="NestedHeadContent" runat="server" />
</asp:Content>

And on my content page page:
<asp:Content ID="Content1" ContentPlaceHolderID="NestedHeadContent"
runat="server">
... .js includes goes here ...
<script type="text/javascript">
$(function()
{
$('.startDate-pick').datePicker({startDate:'01/01/1996'});
});
</script">
</asp:Content>

And in the body of the nested page, i've got this input field with the class
used above:
<input id="startDate" name="startDate" type="text" size="7"
class="startDate-pick" />


This works on content pages within the masterpage, but not on content pages
within the nested masterpage. Why is that, and what can I do about it?

Thanks in advance.

Tommy
 
...
Posted: Tue Oct 13, 2009 3:24 pm
Guest
Hi,

I've also got this problem. Has anybody successfully used jQuery on a nested masterpage?

Thanks,

Mark



Tommy Jakobsen wrote:

MVC, nested masterpage and Javascript
13-Sep-08

Hi.

Is there a problem when trying to use Javascript on a nested masterpage?

On my masterpage, i've got this in the <head>:
<asp:ContentPlaceHolder ID="HeadContent" runat="server" />

And on the nested masterpage:
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<asp:ContentPlaceHolder ID="NestedHeadContent" runat="server" />
</asp:Content>

And on my content page page:
<asp:Content ID="Content1" ContentPlaceHolderID="NestedHeadContent"
runat="server">
... .js includes goes here ...
<script type="text/javascript">
$(function()
{
$('.startDate-pick').datePicker({startDate:'01/01/1996'});
});
</script">
</asp:Content>

And in the body of the nested page, i've got this input field with the class
used above:
<input id="startDate" name="startDate" type="text" size="7"
class="startDate-pick" />


This works on content pages within the masterpage, but not on content pages
within the nested masterpage. Why is that, and what can I do about it?

Thanks in advance.

Tommy

EggHeadCafe - Software Developer Portal of Choice
SEO With Google, MSN, and Yahoo Site: and Link: counts
http://www.eggheadcafe.com/tutorials/aspnet/06d7d9b5-8be3-4052-be2f-d7d870642c44/seo-with-google-msn-and.aspx
 
bruce barker...
Posted: Tue Oct 13, 2009 7:46 pm
Guest
you are trying to attach the picker before the input control is
rendered, so the $('.startDate-pick') returns an empty query. attach at
dom ready (jquery start):

$(function() {
$('.startDate-pick')
.datePicker({startDate:'01/01/1996'});
});

-- bruce (sqlwork.com)

Mark Banfill wrote:
Quote:
Hi,

I've also got this problem. Has anybody successfully used jQuery on a nested masterpage?

Thanks,

Mark



Tommy Jakobsen wrote:

MVC, nested masterpage and Javascript
13-Sep-08

Hi.

Is there a problem when trying to use Javascript on a nested masterpage?

On my masterpage, i've got this in the <head>:
asp:ContentPlaceHolder ID="HeadContent" runat="server" /

And on the nested masterpage:
asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"
asp:ContentPlaceHolder ID="NestedHeadContent" runat="server" /
/asp:Content

And on my content page page:
asp:Content ID="Content1" ContentPlaceHolderID="NestedHeadContent"
runat="server"
... .js includes goes here ...
script type="text/javascript"
$(function()
{
$('.startDate-pick').datePicker({startDate:'01/01/1996'});
});
/script"
/asp:Content

And in the body of the nested page, i've got this input field with the class
used above:
input id="startDate" name="startDate" type="text" size="7"
class="startDate-pick" /


This works on content pages within the masterpage, but not on content pages
within the nested masterpage. Why is that, and what can I do about it?

Thanks in advance.

Tommy

EggHeadCafe - Software Developer Portal of Choice
SEO With Google, MSN, and Yahoo Site: and Link: counts
http://www.eggheadcafe.com/tutorials/aspnet/06d7d9b5-8be3-4052-be2f-d7d870642c44/seo-with-google-msn-and.aspx
 
Mark Banfill...
Posted: Fri Oct 30, 2009 6:22 pm
Guest
I solved my problem. Javascript links need to be adjusted and added again to
the head section of the nested masterpage.


"bruce barker" wrote:

Quote:
you are trying to attach the picker before the input control is
rendered, so the $('.startDate-pick') returns an empty query. attach at
dom ready (jquery start):

$(function() {
$('.startDate-pick')
.datePicker({startDate:'01/01/1996'});
});

-- bruce (sqlwork.com)

Mark Banfill wrote:
Hi,

I've also got this problem. Has anybody successfully used jQuery on a nested masterpage?

Thanks,

Mark



Tommy Jakobsen wrote:

MVC, nested masterpage and Javascript
13-Sep-08

Hi.

Is there a problem when trying to use Javascript on a nested masterpage?

On my masterpage, i've got this in the <head>:
asp:ContentPlaceHolder ID="HeadContent" runat="server" /

And on the nested masterpage:
asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"
asp:ContentPlaceHolder ID="NestedHeadContent" runat="server" /
/asp:Content

And on my content page page:
asp:Content ID="Content1" ContentPlaceHolderID="NestedHeadContent"
runat="server"
... .js includes goes here ...
script type="text/javascript"
$(function()
{
$('.startDate-pick').datePicker({startDate:'01/01/1996'});
});
/script"
/asp:Content

And in the body of the nested page, i've got this input field with the class
used above:
input id="startDate" name="startDate" type="text" size="7"
class="startDate-pick" /


This works on content pages within the masterpage, but not on content pages
within the nested masterpage. Why is that, and what can I do about it?

Thanks in advance.

Tommy

EggHeadCafe - Software Developer Portal of Choice
SEO With Google, MSN, and Yahoo Site: and Link: counts
http://www.eggheadcafe.com/tutorials/aspnet/06d7d9b5-8be3-4052-be2f-d7d870642c44/seo-with-google-msn-and.aspx
 
 
Page 1 of 1    
All times are GMT - 5 Hours
The time now is Wed Dec 02, 2009 1:54 am