栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

Jquery公告滚动+AJAX后台得到数据

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Jquery公告滚动+AJAX后台得到数据

aspx
复制代码 代码如下:




ul, li
{
margin: 0;
padding: 0;
}
#scrollDiv1
{
width: 300px;
height: 25px;
line-height: 25px;
border: #ccc 0px solid;
overflow: hidden;
}
#scrollDiv1 li
{
height: 25px;
padding-left: 10px;
}
#scrollDiv2
{
width: 300px;
height: 25px;
line-height: 25px;
border: #ccc 0px solid;
overflow: hidden;
}
#scrollDiv2 li
{
height: 25px;
padding-left: 10px;
}



<%--头部部分--%>
border="0">






















公告:












<%--头部部分结束--%>
后台Util/MainUtil.aspx.cs输出对应的 HTML 的数据
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace Web.Util
{
public partial class MainUtil : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
int k = int.Parse(Request["param"].ToString());
switch (k)
{
case 1:
toOne();
break;
case 2:
toTwo();
break;
default:
break;
}
}
catch { }
}
private void toOne()
{
try
{
string st = String.Empty;
string companyName = Request["nameparam"].ToString();
DataTable dt1 = DBUtility.DbHelperSQL.Query("select top(5) Title,Id from 公告表 where TypeId='2' And Creater='" + companyName + "'order by CreatTime desc").Tables[0];
for (int i = 0; i < dt1.Rows.Count; i++)
{
//把公告做成超链接
st += "
  • " + dt1.Rows[i]["Title"].ToString() + "
  • ";
    }
    showHtml(st);
    }
    catch { }
    }
    private void toTwo()
    {
    try
    {
    string st = String.Empty;
    string companyName= Request["nameparam"].ToString();
    DataTable dt2= DBUtility.DbHelperSQL.Query("select top(5) Title,Id from 公告表 where Id IN (select top 10 Id from 公告表 where TypeId='2' And Creater='"+companyName+"'order by CreatTime desc) order by CreatTime asc").Tables[0];
    //把公告做成超链接
    for (int i = 0; i < dt2.Rows.Count; i++)
    {
    st += "
  • " + dt2.Rows[i]["Title"].ToString() + "
  • ";
    }
    showHtml(st);
    }
    catch { }
    }
    private void showHtml(string st){
    Response.ContentType = "text/html";//text/html,和application/json 都是输出格式
    Response.Write(st);
    Response.Flush();
    Response.Close();
    }
    }
    }

    转载请注明:文章转载自 www.mshxw.com
    本文地址:https://www.mshxw.com/it/114276.html
    我们一直用心在做
    关于我们 文章归档 网站地图 联系我们

    版权所有 (c)2021-2022 MSHXW.COM

    ICP备案号:晋ICP备2021003244-6号