在 DetailsView 插入/编辑模板中使用 JQuery datepicker()
我很难让 jquery datepicker 与我的 DetailsView 插入模板一起使用。我已经尝试了多种方法来尝试使其发挥作用,但在模板控件内并未成功。该代码在 DetailsView 之外工作正常,但我需要它在里面。这是我的代码:
<link href="jquery-ui-1.7.3.custom.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript" src"jquery-ui-1.7.3.custom.min.js"></script>
<script type="text/javascript" language="javascript" src"jquery-1.6.2.min.js"></script>
<script type="text/javascript" language="javascript">
function pageLoad(sender, args)
{
$('.DateControl').datepicker();
};
</script>
<asp:templatefield HeaderText="Action Date" SortExpression="Action_Date">
<InsertItemTemplate>
<asp:Textbox runat="server" Text='<%# Bind("Action_Date") %>' id="textAction" CssClass="DateControl">
</asp:textBox>
</InsertItemTemplate>
</script>
任何有关我可能做错的事情的帮助都会有所帮助。哦,我正在使用 SharePoint,我将无法使用日期选择器的 Ajax 控件。
I am having a hard time getting the jquery datepicker to work with my DetailsView insert template. I have tried numorous ways of trying to get this to work and I have not been successful inside of the Template control. The code works fine outside of the DetailsView, but I need it inside. Here is my code:
<link href="jquery-ui-1.7.3.custom.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript" src"jquery-ui-1.7.3.custom.min.js"></script>
<script type="text/javascript" language="javascript" src"jquery-1.6.2.min.js"></script>
<script type="text/javascript" language="javascript">
function pageLoad(sender, args)
{
$('.DateControl').datepicker();
};
</script>
<asp:templatefield HeaderText="Action Date" SortExpression="Action_Date">
<InsertItemTemplate>
<asp:Textbox runat="server" Text='<%# Bind("Action_Date") %>' id="textAction" CssClass="DateControl">
</asp:textBox>
</InsertItemTemplate>
</script>
Any help on what I could possibly doing wrong would be helpful. oh, and I am working with SharePoint and I will not be able to use the Ajax Controls for a datepicker.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否使用 Firebug (或类似的)来验证您的 pageLoad() 函数是否被调用?对于与 jQuery 一起使用,我发现以下符号更为常见,对于在页面加载时必须仅执行一次的代码:
我的理解是 pageLoad() 可能会出现名称冲突,而符号以上比较靠谱。
乍一看,您的日期选择器初始化代码本身似乎是正确的。
Have you used Firebug (or similar) to verify that your pageLoad() function is being called? For use with jQuery, I've found the following notation to be much more common, for code which must be executed just once, when the page loads:
My understanding is that there can be name-collisions with pageLoad(), whereas the notation above is more reliable.
At a glance, your datepicker intialization code itself seems correct.