2017-02-17 22 views
0

我有一个包含多个UpdatePannel的页面,它们都是可见的,我点击一个按钮后会一个接一个地显示它们。 我想使用引导日期时间选择器,但我的问题是脚本不是由浏览器符文。ASP.NET主页<script>没有运行

<script type="text/javascript"> 
    $(function() { 
     $('#datetimepicker1').datetimepicker(); 
    }); 
</script> 

如果我在控制台中运行这一切都工作。 关于如何强制执行脚本的任何想法?

按照要求:

$(function() { 
    $('#datetimepicker1').datetimepicker(); 
}); 
init[1]0: documentcontext: documentURL: "http://localhost:52261/Dashboard.aspx"activeElement: bodyalinkColor: ""all: HTMLAllCollection[520]anchors: HTMLCollection[0]applets: HTMLCollection[0]baseURI: "http://localhost:52261/Dashboard.aspx"bgColor: ""body: bodycharacterSet: "UTF-8"charset: "UTF-8"childElementCount: 1childNodes: NodeList[2]children: HTMLCollection[1]compatMode: "CSS1Compat"contentType: "text/html"cookie: ""cphNavigation_imgProfile: undefinedcurrentScript: nulldefaultView: WindowdesignMode: "off"dir: ""doctype: <!DOCTYPE html>documentElement: htmldocumentURI: "http://localhost:52261/Dashboard.aspx"domain: "localhost"embeds: HTMLCollection[0]fgColor: ""firstChild: <!DOCTYPE html>firstElementChild: htmlfonts: FontFaceSetforms: HTMLCollection[1]head: headhidden: falseimages: HTMLCollection[1]implementation: DOMImplementationinputEncoding: "UTF-8"isConnected: truejQuery19107336506808681962: 1lastChild: htmllastElementChild: htmllastModified: "02/17/2017 11:51:13"linkColor: ""links: HTMLCollection[68]location: LocationnextSibling: nullnodeName: "#document"nodeType: 9nodeValue: nullonabort: nullonauxclick: nullonbeforecopy: nullonbeforecut: nullonbeforepaste: nullonblur: nulloncancel: nulloncanplay: nulloncanplaythrough: nullonchange: nullonclick: nullonclose: nulloncontextmenu: nulloncopy: nulloncuechange: nulloncut: nullondblclick: nullondrag: nullondragend: nullondragenter: nullondragleave: nullondragover: nullondragstart: nullondrop: nullondurationchange: nullonemptied: nullonended: nullonerror: nullonfocus: nulloninput: nulloninvalid: nullonkeydown: nullonkeypress: nullonkeyup: nullonload: nullonloadeddata: nullonloadedmetadata: nullonloadstart: nullonmousedown: nullonmouseenter: nullonmouseleave: nullonmousemove: nullonmouseout: nullonmouseover: nullonmouseup: nullonmousewheel: nullonpaste: nullonpause: nullonplay: nullonplaying: nullonpointercancel: nullonpointerdown: nullonpointerenter: nullonpointerleave: nullonpointerlockchange: nullonpointerlockerror: nullonpointermove: nullonpointerout: nullonpointerover: nullonpointerup: nullonprogress: nullonratechange: nullonreadystatechange: nullonreset: nullonresize: nullonscroll: nullonsearch: nullonseeked: nullonseeking: nullonselect: nullonselectionchange: nullonselectstart: nullonshow: nullonstalled: nullonsubmit: nullonsuspend: nullontimeupdate: nullontoggle: nullonvolumechange: nullonwaiting: nullonwebkitfullscreenchange: nullonwebkitfullscreenerror: nullonwheel: nullorigin: "http://localhost:52261"ownerDocument: nullparentElement: nullparentNode: nullplugins: HTMLCollection[0]pointerLockElement: nullpreferredStylesheetSet: nullpreviousSibling: nullreadyState: "complete"referrer: "http://localhost:52261/Default.aspx"rootElement: nullscripts: HTMLCollection[18]scrollingElement: bodyselectedStylesheetSet: nullstyleSheets: StyleSheetListtextContent: nulltitle: "Credit Hire Portal"visibilityState: "visible"vlinkColor: ""webkitCurrentFullScreenElement: nullwebkitFullscreenElement: nullwebkitFullscreenEnabled: truewebkitHidden: falsewebkitIsFullScreen: falsewebkitVisibilityState: "visible"xmlEncoding: nullxmlStandalone: falsexmlVersion: null__proto__: HTMLDocumentlength: 1__proto__: Object[0] 

更新1 在主页我有2个contentplaceholders,一个用于导航栏和所述第二用于多步骤的形式(在这里我有的DateTimePicker)。 如果我把的DateTimePicker上的导航内容的所有工作... :(

+0

该脚本是在你的js库的声明下? – Tinwor

+0

datetimepicker的声明在头,脚本在底部 –

+0

你有没有在你的页面中有一个id为“datetimepicker1”的元素?页面加载时浏览器控制台中是否确实没有错误? “document.ready”部分是否正在运行?即你可以把一个console.log放在datetimepicker的调用之上,以证明整个函数正在运行吗? – ADyson

回答

0

你需要确保你的脚本所有的.js的所有声明下(库文件)。

例。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.45/js/bootstrap-datetimepicker.min.js"></script> 
<script src="Link of other.js"></script> 

<script type="text/javascript"> 
$(function() { 
     $('#datetimepicker1').datetimepicker(); 
    }); 
</script> 

还可以看到脚本错误在浏览器的控制台窗口。 前,在Chrome浏览器中按F12键,并单击控制台。它会显示你的脚本的错误。

+0

我确定订单没问题。 –

+0

如果在脚本中出现错误,您需要尝试检查帮助您的控制台窗口。 –