Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am using master pages with child pages for my project.

For a datepicker in child page i am trying to use jquery plugin.

In debugging i found that the code after reading the jquery source lines, function is not read at all and the cursor moves to unload event in vb.

I am using the code in header of child page.

So though their is no error message but the datepicker is not working.
I have used similar code in a single webpage project and it worked fine.

Pls suggest. thanks!

The code:

<header>
<link rel="stylesheet" href="<%=ResolveUrl("~/Scripts/jquery-ui-1.11.1.datepicker/jquery-ui.css")%>"/>
<script src="<%=ResolveUrl("~/Scripts/jquery-1.11.1.js")%>"></script>
<script src="<%=ResolveUrl("~/Scripts/jquery-ui-1.11.1.datepicker/jquery-ui.js")%>"></script>
***** <script type="text/javascript">
$(function () {
$("#txtTargetDate").datepicker({ dateformat: "dd-mm-yy" });
$("#txtTargetDate").datepicker("option", "dateFormat", "dd-mm-yy");
});
</script>

</header>
Posted
Updated 6-Sep-14 19:24pm
v3

Hi
the cause can be several, maybe you are not use the correct ID, when the asp.net page is generated the ID of the control is different. try to using ClientID as static. See

http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientid(v=vs.110).aspx[^]

for detail

I recommended also that run your code inside $(document).ready() function
See:

http://learn.jquery.com/using-jquery-core/document-ready/[^]

I hope this help
 
Share this answer
 
v2
Found solution from a book this time.

I did'nt knew books still are useful after google :-)

1. I Created a Script Manager in the master page and referred the scripts in that.
2. Linked css in header of master page.
3. And added function in the content page through a javascript file.

This may help if anybody faces similar issue:

Pls note that positioning of script is very important hence location included.

In master page:

css file link:

XML
<head runat="server">
    <link rel="stylesheet" href="~/Scripts/jquery-ui-1.11.1.datepicker/jquery-ui.css"  type="text/css"/>


Jquery refer:

XML
<form id="form1" runat="server">

   <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
             <Scripts>
                 <asp:ScriptReference Path="~/Scripts/jquery-1.11.1.js" />
                 <asp:ScriptReference Path="~/Scripts/jquery-ui-1.11.1.datepicker/jquery-ui.js" />
             </Scripts>
    </asp:ScriptManager>


 <div id ="pagewrapper">



In content page:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<script src="../../Scripts/textboxdate.js" type="text/javascript"></script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900