Click here to Skip to main content
15,896,207 members

why my jquery is not working inside the content page ?

MurugappanCTS asked:

Open original thread
I am having a jquery function for datetime picker and i have called that function in master page header and when i am giving datetime values in child page datetimepicker is loading only once when form is loading newly after i am pressing submit button
datetimepicker is not functioning second time what is the reason

Mymasterpage code is :
XML
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="NewMaster.master.cs" Inherits="NewMaster" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>CMS</title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
    <link rel="shortcut icon" href="favicon.ico" />
    <link rel="icon" type="image/gif" href="animated_favicon1.gif" />
    <link href="style.css" rel="stylesheet" type="text/css" />
    <link href="gridview.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="styles/style.css" media="screen" />
    <link href="styles/styles_masterpage.css" rel="stylesheet" type="text/css" />

    <script language="javascript" type="text/javascript" src="scripts/Validation.js"></script>

    <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>

    <script type="text/javascript" src="js/jquery-ui-1.8.19.custom.min.js"></script>

    <link type="text/css" href="css/ui-lightness/jquery-ui-1.8.19.custom.css" rel="stylesheet" />
    <style type="text/css">
        body, html
        {
            overflow-x: hidden;
        }
        .style1
        {
            width: 374px;
        }
    </style>
</head>

<script type="text/JavaScript">
<!--
    function MM_swapImgRestore() { //v3.0
        var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
    }

    function MM_preloadImages() { //v3.0
        var d = document; if (d.images) {
            if (!d.MM_p) d.MM_p = new Array();
            var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
                if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
        }
    }

    function MM_findObj(n, d) { //v4.01
        var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
            d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
        }
        if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
        for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
        if (!x && d.getElementById) x = d.getElementById(n); return x;
    }

    function MM_swapImage() { //v3.0
        var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
            if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
    }
//-->
</script>

<body>
    <form id="form1" runat="server">
    <div>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td colspan="2" width="100%">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td colspan="3">
                                <img src="images/header_strip.jpg" alt="" style="height: 0px; width: 100%" />
                            </td>
                        </tr>
                        <tr>
                            <td class="top_bg">
                                <div align="left">
                                    <a href="">
                                        <img name="top" hspace="8" border="0" id="top" src="images/Buttons/logo.jpg" />
                                    </a>
                                </div>
                            </td>
                            <td align="center">
                                <asp:Image ID="Image1" runat="server" ImageUrl="~/images/c1.gif" />
                            </td>
                            <td class="vv_bg">
                                <div align="right">
                                    <a href="">
                                        <img name="justclick" hspace="8" border="0" id="Img1" src="images/justclick.png" />
                                    </a>
                                </div>
                            </td>
                            <td valign="middle" class="top_bg">
                            </td>
                        </tr>
                        <tr>
                            <td align="right" colspan="2">
                                <table>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td align="center" width="100%" colspan="2">
                    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="nav_bg" style="background-color: #5C6A84">
                        <tr>
                            <td align="right">
                                <table>
                                    <tr>
                                        <td>
                                            <asp:Label ID="Label2" runat="server" BorderColor="#7A2784" Font-Bold="True" Font-Italic="False"
                                                Font-Names="Times New Roman" Font-Size="Larger" ForeColor="#FFFFFF" Width="179px"
                                                Style="margin-left: 0px"> Welcome   To CMS :<%= Session["username"]%> </asp:Label>
                                        </td>
                                        <td>
                                            <asp:LinkButton ID="LinkButton2" runat="server" Font-Bold="True" OnClick="LinkButton1_Click"
                                                Style="color: #FFFFFF;">SignOut</asp:LinkButton>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td align="left" width="13%" class="menualign" valign="top">
                    <%--<table width="100%">
                        <tr>
                            <td>--%>
                                <asp:Menu ID="menuSlide" runat="server" DataSourceID="XmlDataSource1" Orientation="Vertical"
                                    BackColor="Silver" align="left" Font-Size="Medium" Width="100%" StaticMenuItemStyle-HorizontalPadding="5px"
                                    OnMenuItemClick="menuSlide_MenuItemClick">
                                    <DataBindings>
                                        <asp:MenuItemBinding DataMember="MenuItem" NavigateUrlField="NavigateUrl" TextField="Text"
                                            ToolTipField="ToolTip" />
                                    </DataBindings>
                                    <StaticMenuItemStyle ItemSpacing="8" CssClass="staticMenuItemStyle" />
                                    <StaticSelectedStyle CssClass="staticMenuItemSelectedStyle" />
                                    <DynamicMenuItemStyle CssClass="dynamicMenuItemStyle" />
                                </asp:Menu>
                            <%--</td>
                        </tr>
                    </table>--%>
                </td>
                <td align="left" width="87%" valign="top">
                    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                    </asp:ContentPlaceHolder>
                </td>
            </tr>
            <tr>
                <td height="35" bgcolor="#5C6A84" colspan="2" width="100%">
                    <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tr>
                            <td class="style1" style="margin-left: 0px; color: #FFFFFF;">
                                Copyright &copy; 2009 All Rights Reserved.
                            </td>
                            <td width="60%" class="White" style="padding-right: 0px;" align="right">
                                <div style="padding-right: 0px; color: #FFFFFF;">
                                    Powered By: <a href="http://www.Veeserv.com" target="_blank" class="b" style="color: #FFFFFF;">
                                        VeeServ Technologies Pvt.Ltd</a>
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2" width="100%">
                    <asp:XmlDataSource ID="XmlDataSource1" TransformFile="~/Menu/TransformXSLT.xslt"
                        XPath="MenuItems/MenuItem" runat="server"></asp:XmlDataSource>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>






And content page code is


XML
<%@ Page Language="C#" MasterPageFile="~/NewMaster.master" AutoEventWireup="true" CodeFile="DAttd.aspx.cs" Inherits="DAttd" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server" >





</asp:Content>





<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">







    <script type="text/javascript">
        $(document).ready(function() {
            $("#<%=TextBox1.ClientID %>").datepicker();


        });
    </script>


<script language="javascript" type="text/javascript">
     function ltrim(s)
{
    return s.replace( /^\s*/, "");
}

function trim(s)
{
    //s=s.replace(/^\s*/,"");
    return s.replace(/^\s+|\s+$/g,"");
}
   function Daily() {
    var da= document.getElementById('<%=TextBox1.ClientID %>');
    var ay = document.getElementById('<%=DropDownList2.ClientID %>');
    var co = document.getElementById('<%=DropDownList3.ClientID %>');
    var ty = document.getElementById('<%=DropDownList4.ClientID %>');

    if(ltrim(da.value) == "")
    { da.style.background = 'Yellow'; alert("Please select the date of birth !"); da.focus(); return false; }
    else
    { da.style.background = 'White'; }
    if (ay.selectedIndex == 0)
    { ay.style.background = 'Yellow'; alert("Please select the Academic Year !"); ay.focus(); return false; }
    else
    { ay.style.background = 'White'; }
    if (co.selectedIndex == 0)
    { co.style.background = 'Yellow'; alert("Please select the Course !"); co.focus(); return false; }
    else
    { co.style.background = 'White'; }
    if (ty.selectedIndex == 0)
    { ty.style.background = 'Yellow'; alert("Please select the type !"); ty.focus(); return false; }
    else
    { ty.style.background = 'White'; }
}





</script>

<asp:ScriptManager ID="scriptmanager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="updatepanel1" runat="server">
<ContentTemplate>

    <div style="width: 100%;">
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td width="95%" valign="top" bgcolor="#FFFFFF">
                    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">

                        <tr>

                            <td width="100%" valign="top">
                                <table width="100%" border="0" cellspacing="0" cellpadding="2" style="background-color: #ffffff">
                                    <tr>
                                        <td align="center">
                                            <%--<asp:Label ID="Label2" runat="server" Style="font-size: 14pt; color: #2B6799; font-family: Verdana">
                                                      College Details</asp:Label>--%>
                                            <img src="images/Head/stfdaly.PNG" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="left" width="100%">
                                            <table width="66%" align="center">
                                                <tr>
                                                    <td align="left" width="24%">
                                                        <asp:Label ID="Label3" runat="server" CssClass="lbl" Text="Date"></asp:Label>
                                                    </td>
                                                    <td style="height: 6px" width="2%">
                                                        :
                                                    </td>
                                                    <td align="left" width="24%">
                                                        <%--<a href="javascript: NewCal('TextBox1','MMDDYYYY');">--%>
                                                            <asp:TextBox ID="TextBox1" runat="server" AutoCompleteType="Disabled" CssClass="normal"
                                                                onblur="this.className='normal'" onfocus="this.className='focus'" Width="100px"></asp:TextBox>
                                                            <%--<img id="IMG3" alt="" border="0" onclick="return IMG1_onclick()" src="Date-Picker.gif" /></a>--%>
                                                    </td>
                                                    <td align="left" width="24%">
                                                        <asp:Label ID="Label4" runat="server" CssClass="lbl" Text="Academic Year"></asp:Label>
                                                    </td>
                                                    <td style="height: 6px" width="2%">
                                                        :
                                                    </td>
                                                    <td align="left" width="24%">
                                                        <asp:DropDownList ID="DropDownList2" runat="server" Width="120px">
                                                        </asp:DropDownList>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="left" width="24%">
                                                        <asp:Label ID="Label5" runat="server" CssClass="lbl" Text="Department"></asp:Label>
                                                    </td>
                                                    <td style="height: 6px" width="2%">
                                                        :
                                                    </td>
                                                    <td align="left" width="24%">
                                                        <asp:DropDownList ID="DropDownList3" runat="server" Width="120px">
                                                        </asp:DropDownList>
                                                    </td>
                                                    <td align="left" width="24%">
                                                        <asp:Label ID="Label6" runat="server" CssClass="lbl" Text="Type"></asp:Label>
                                                    </td>
                                                    <td style="height: 6px" width="2%">
                                                        :
                                                    </td>
                                                    <td align="left" width="24%">
                                                        <asp:DropDownList ID="DropDownList4" runat="server" Width="120px">
                                                        </asp:DropDownList>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="center" width="100%" colspan="6">
                                                        <asp:Button ID="Button5" runat="server" CssClass="Fetch" OnClick="Button5_Click"
                                                            OnClientClick="return Daily()" />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right" width="50%" colspan="3">
                                                        <asp:CheckBox ID="CheckBox1" runat="server" Font-Bold="True" Text="Select All Morning"
                                                            AutoPostBack="True" OnCheckedChanged="CheckBox1_CheckedChanged" />
                                                    </td>
                                                    <td align="left" width="50%" colspan="3">
                                                        <asp:CheckBox ID="CheckBox2" runat="server" Font-Bold="True" Text="Select All Afternoon"
                                                            AutoPostBack="True" OnCheckedChanged="CheckBox2_CheckedChanged" />
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center">
                                            <br />
                                            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="100%"
                                                GridLines="None" CssClass="mGrid" PagerStyle-CssClass="pgr" BorderStyle="None"
                                                BorderWidth="1px" CellPadding="3" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging"
                                                Font-Names="MS Sans Serif" OnRowDataBound="GridView1_RowDataBound">
                                                <Columns>
                                                    <asp:BoundField HeaderText="Employee" DataField="EN">
                                                        <HeaderStyle Font-Size="8pt" />
                                                    </asp:BoundField>
                                                    <asp:TemplateField>
                                                        <HeaderTemplate>
                                                            Morning
                                                        </HeaderTemplate>
                                                        <ItemTemplate>
                                                            <asp:CheckBox ID="chk" runat="server" />
                                                        </ItemTemplate>
                                                        <ItemStyle HorizontalAlign="Center" />
                                                    </asp:TemplateField>
                                                    <asp:TemplateField>
                                                        <ItemTemplate>
                                                            <asp:DropDownList ID="ddl" runat="server" DataTextField="LNAME" DataValueField="LNAME"
                                                                AppendDataBoundItems="true">
                                                            </asp:DropDownList>
                                                        </ItemTemplate>
                                                        <ItemStyle HorizontalAlign="Center" />
                                                        <HeaderTemplate>
                                                            Morning Leave
                                                        </HeaderTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField>
                                                        <ItemTemplate>
                                                            <asp:CheckBox ID="cb" runat="server" />
                                                        </ItemTemplate>
                                                        <ItemStyle HorizontalAlign="Center" />
                                                        <HeaderTemplate>
                                                            Afternoon
                                                        </HeaderTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField>
                                                        <ItemTemplate>
                                                            <asp:DropDownList ID="ddl2" runat="server">
                                                            </asp:DropDownList>
                                                        </ItemTemplate>
                                                        <ItemStyle HorizontalAlign="Center" />
                                                        <HeaderTemplate>
                                                            Afternoon Leave
                                                        </HeaderTemplate>
                                                    </asp:TemplateField>
                                                </Columns>
                                                <%--<FooterStyle BackColor="White" ForeColor="#000066" />
                                                <RowStyle ForeColor="#000066" />
                                                <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                                                <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Center" />
                                                <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                                                <PagerSettings Mode="NumericFirstLast" />--%>
                                            </asp:GridView>
                                            <asp:Label ID="Label2" runat="server"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center">
                                            <asp:Button ID="Button1" runat="server" Style="display: none;" OnClick="Button1_Click" />
                                            <asp:Button ID="Button3" runat="server" CssClass="Save" OnClick="Button3_Click" />
                                            <asp:Button ID="Button4" runat="server" Style="display: none;" OnClick="Button4_Click" />
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>

                    </table>
                </td>
            </tr>
        </table>
    </div>


</ContentTemplate>

</asp:UpdatePanel>
</asp:Content>
Tags: ASP.NET4.0

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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