Because it is part of the project, I am only part of it.CodeFor details, refer:
<Table width = " 100% " Border = " 0 " Cellspacing = " 0 " Cellpadding = " 5 " > <Tr> <TD id = " Latestnews " Height = " 330 " Align = " Center " Valign = " Top " Class = " Font14 " Style = " Border: #7baed9 solid 1px; Border-top: none; padding: 10px; " > </TD> </tr> </table>
It is mainly used to obtain data through jquery Ajax and display it in the ID number "latestnews" TD. The following is the Ajax code:
<SCRIPT type = " Text/JavaScript " > $ (Function () {$. Ajax ({type: " Post " , URL: " Ceo2012/latestnews. ashx " , Contenttype: " APP/JSON; charset = UTF-8 " , Datatype: " JSON " , Success: function (data) {$ ( " # Latestnews " ).Html (data) ;}, error: function (error) {$ ( " # Latestnews " Pai.html ( " No information has been published! " );}});}); </SCRIPT>
Below is a general method for processing latestnews. ashx in the ceo2012 Folder:
/// <Summary> /// Latest media reports /// </Summary> /// <Param name = "context"> </param> Public Void Processrequest (httpcontext context) {context. response. contenttype = " Text/plain " ; JavascriptserializerJavascriptSerializer = New Javascriptserializer (); string strhtml = " <Ul style = 'text-align: left'> " ; Datatable dt = New Datatable (); newsrule = New Newsrule (); dt = Newsrule. getnewsbytid ( 640 , 15 , " Sortid DESC " ); If (Dt. Rows. Count = 0 ) {Context. response. Write ( " No information has been published! " ); Return ;} For ( Int I = 0 ; I <DT. Rows. Count; I ++){ If (! String. isnullorempty (Dt. Rows [I] [ " Aurl " ]. Tostring () {strhtml + = " <Li> <a href =' " + Dt. Rows [I] [ " Aurl " ]. Tostring () + " 'Title =' " + Dt. Rows [I] [ " Title " ]. Tostring () + " 'Target = \ "_ blank \"> " + Dt. Rows [I] [ " Title " ]. Tostring () + " </A> " ;} Else {Strhtml + = " <Li> <a href = \ "http://www.sino-manager.com/ " + Returndate (datetime. parse (Dt. Rows [I] [ " Pubtime " ]. Tostring (). tow.datestring () + " _ " + Dt. Rows [I] [ " Postid " ]. Tostring () +" . Html \ "Title = \" " + Dt. Rows [I] [ " Title " ]. Tostring () + " \ "Target = \" _ blank \ "> " + Dt. Rows [I] [ " Title " ]. Tostring () + " </A> </LI> " ;} Strhtml + = " </Ul> " ; String content = Javascriptserializer. serialize (strhtml); context. response. Write (content );