嵌套ascx控件中的JQueryUI DatePicker; sub-ascx datepicker不起作用

时间:2014-08-02 22:16:57

标签: jquery jquery-ui-datepicker

我在ascx控件中有一个jquery .datepicker,在第一个ascx中有一个ascx中的第二个。子控件中的那个不起作用。

当我将鼠标悬停在第一个控件中的图像上时,它会在子控件中给出图像的路径,而不是第一个控件。

我该如何解决这个问题?我在stackoverflow和其他人上搜索了无数的问题,并且没有找到类似的东西。这些日期选择器位于同一页面上的两个独立控件中。

以下是代码:

    <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" />
&#39;类型=&#34;文本/ JavaScript的&#34;&GT; &#39;类型=&#34;文本/ JavaScript的&#34;&GT;
 <script type="text/javascript">
     $(function () {
         $('#' + '<%= txtDateofBirth.ClientID %>').datepicker({
             changeMonth: true,
             changeYear: true,
             yearRange: '1910:' + new Date(1910, 1 - 1, 1).getYear,
             minDate: new Date(1910, 1 - 1, 1),
             maxDate: new Date(new Date(1910, 1 - 1, 1).getYear, 1 - 1, 1)
         });
     });
     $.datepicker.setDefaults({
         showOn: "both",
         buttonImageOnly: true,
         buttonImage: '<%=ResolveUrl("Images/Icons/Classy24/calendar_date.png") %>'
     });

<input type="text" id="txtDateofBirth" name="txtDateofBirth" runat="server" width="100"/>

第一控制内的第二控制: (这是在文件夹名称中控制第一个控件的文件夹

    <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" />
&#39;类型=&#34;文本/ JavaScript的&#34;&GT; &#39;类型=&#34;文本/ JavaScript的&#34;&GT;
 <script type="text/javascript">
     $(function () {
         $('#' + '<%= txtDepDateofBirth.ClientID %>').datepicker({
             changeMonth: true,
             changeYear: true,
             yearRange: '1910:' + new Date(1910, 1 - 1, 1).getYear,
             minDate: new Date(1910, 1 - 1, 1),
             maxDate: new Date(new Date(1910, 1 - 1, 1).getYear, 1 - 1, 1)
         });
     });
     $.datepicker.setDefaults({
         showOn: "both",
         buttonImageOnly: true,
         buttonImage: '<%=ResolveUrl("Images/Icons/Classy24/calendar_date.png") %>'
     });

<input type="text" id="txtDepDateofBirth" name="txtDepDateofBirth" runat="server" width="100"/>

注意:两种情况下的按钮图像编码为:     buttonImage:&#39;&lt;%= ResolveUrl(&#34; Images / Icons / Classy24 / calendar_date.png&#34;)%&gt;&#39;

我有两个地方的形象:

maincontrol.ascx /图像/图标/等

maincontrol文件夹/ controls / images / icons等。

当我将鼠标悬停在主控制器的图像上时,我会获得控件/图像位置,而不是maincontrol.ascx / images等位置。

谢谢!当然,我会将正确的答案标记为答案。

1 个答案:

答案 0 :(得分:0)

我编辑了上面的代码以便它是正确的;在研究之后我发现这条线现在正确了:

$('#' + '<%= txtDepDateofBirth.ClientID %>').datepicker({

被错误地写为:

$('#' + 'txtDepDateofBirth.ClientID %>').datepicker({

离开:

<%= 

我希望这个例子可以帮助某人尝试做同样的事情