从数据库中加载Jquery新闻滑块中的数据 [英] Loading Data In Jquery News Slider From Database

查看:64
本文介绍了从数据库中加载Jquery新闻滑块中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上使用了一个jquery新闻滑块。

这是滑块的代码。

< script> 
function tick2(){
$(' #ticker_02 li:first')。slideUp( function (){$( this ).appendTo($(' #ticker_02'))。slideDown();}) ;
}
setInterval( function (){tick2()}, 3000 ) ;
< / script>



Asp.net代码:

 <   ul     id   =  ticker_02    class   =  ticker        runat   =  server >  



C#从数据库加载数据的代码。

列表< refnoticeboard> mgsl =( from  r  in  context.RefNoticeBoards  where  r.Active ==  true   select  r).ToList(); 

foreach (RefNoticeBoard i in mgsl)
{
HtmlGenericControl newLi = new HtmlGenericControl( li< /跨度>);
// newLi.InnerText = d.DeptName;
HtmlGenericControl anchor = < span class =code-keyword> new
HtmlGenericControl( a);
var navlink = i.NavgURL;
anchor.Attributes.Add( href,navlink);
anchor.InnerText = i.NoticeDate + + i.NoticeText;
newLi.Controls.Add(anchor);
ticker_02.Controls.Add(newLi);
}



当我静态地在UL中添加数据时它工作正常但是当我通过数据库提供数据时,它不起作用。

解决方案

' #ticker_02 li:first').slideUp( function (){


this )。appendTo(


' #ticker_02' ))。滑下(); });
}
setInterval( function (){tick2()}, 3000 ) ;
< / script>



Asp.net代码:

 <   ul     id   =  ticker_02    class   =  ticker        runat   =  server >  



C#从数据库加载数据的代码。

列表< refnoticeboard> mgsl =( from  r  in  context.RefNoticeBoards  where  r.Active ==  true   select  r).ToList(); 

foreach (RefNoticeBoard i in mgsl)
{
HtmlGenericControl newLi = new HtmlGenericControl( li< /跨度>);
// newLi.InnerText = d.DeptName;
HtmlGenericControl anchor = < span class =code-keyword> new
HtmlGenericControl( a);
var navlink = i.NavgURL;
anchor.Attributes.Add( href,navlink);
anchor.InnerText = i.NoticeDate + + i.NoticeText;
newLi.Controls.Add(anchor);
ticker_02.Controls.Add(newLi);
}



当我静态地在UL中添加数据时它工作正常但是当我通过数据库提供数据时,它不起作用。


I am using a jquery news slider in my website.
This is the code of slider.

<script>
    function tick2() {
        $('#ticker_02 li:first').slideUp(function () { $(this).appendTo($('#ticker_02')).slideDown(); });
    }
    setInterval(function () { tick2() }, 3000);
</script>


Asp.net code:

<ul id="ticker_02" class="ticker"   runat="server">


C# Code for loading data from database.

List<refnoticeboard> mgsl = (from r in context.RefNoticeBoards where r.Active == true select r).ToList();

        foreach (RefNoticeBoard i in mgsl)
        {
            HtmlGenericControl newLi = new HtmlGenericControl("li");
            //newLi.InnerText = d.DeptName ;
            HtmlGenericControl anchor = new HtmlGenericControl("a");
            var navlink = i.NavgURL;
            anchor.Attributes.Add("href", navlink);
            anchor.InnerText = i.NoticeDate + " " + i.NoticeText;
            newLi.Controls.Add(anchor);
            ticker_02.Controls.Add(newLi);
        }


It''s working fine when i add data in UL statically but when i give data through database it''s don''t work.

解决方案

('#ticker_02 li:first').slideUp(function () {


(this).appendTo(


('#ticker_02')).slideDown(); }); } setInterval(function () { tick2() }, 3000); </script>


Asp.net code:

<ul id="ticker_02" class="ticker"   runat="server">


C# Code for loading data from database.

List<refnoticeboard> mgsl = (from r in context.RefNoticeBoards where r.Active == true select r).ToList();

        foreach (RefNoticeBoard i in mgsl)
        {
            HtmlGenericControl newLi = new HtmlGenericControl("li");
            //newLi.InnerText = d.DeptName ;
            HtmlGenericControl anchor = new HtmlGenericControl("a");
            var navlink = i.NavgURL;
            anchor.Attributes.Add("href", navlink);
            anchor.InnerText = i.NoticeDate + " " + i.NoticeText;
            newLi.Controls.Add(anchor);
            ticker_02.Controls.Add(newLi);
        }


It''s working fine when i add data in UL statically but when i give data through database it''s don''t work.


这篇关于从数据库中加载Jquery新闻滑块中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆