[英]Jquery DateTimePicker not working with asp.net master page and content page
[英]Set jQuery selector on asp.net code behind variable in Content Page that comes from a Master Page control
我有一個位於母版頁上的ASP LinkButton控件。 在一個內容頁面上,當用戶從某個頁面進入該頁面時,我想為該元素設置滾動到動畫。
我想做的是基於VB.net字符串變量(從控件的ID設置)動態設置jQuery選擇器
ContentPage.aspx:
$('body').animate({
scrollTop: $('#<%= scrollToControl %>').offset().top + 'px'
}, 500, 'swing');
ContentPage.aspx.vb
Dim scrollToControl As String = CType(Master.FindControl("someControl"), LinkButton).ClientID
這是獲取ID,但是當我嘗試更新ContentPage.aspx時得到
scrollToControl is not declared. It may be inaccessible due to its protection level
PS我應該完全從后面的代碼中添加jQuery代碼,而不是僅更改選擇器嗎?
您的問題是Dim
實際上將某些內容聲明為私有。 嘗試使用Protected
或Public
聲明字符串。
Protected scrollToControl As String = CType(Master.FindControl("someControl"), LinkButton).ClientID
希望有幫助!
另外,關於您的PS:這樣做的方式或使用RegisterClientScriptBlock
從代碼隱藏的方式都很好(imho)。 我認為這取決於個人偏好,建議您保持一致。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.