2017-02-17 21 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

如果在腳本中出現錯誤,您需要嘗試檢查幫助您的控制檯窗口。 –