| 发表于:2007-09-06 11:01:051楼 得分:0 |
怎么没人关注呀?? 我把源码也贴上吧。 cs using system; using system.data; using system.configuration; using system.collections; using system.web; using system.web.security; using system.web.ui; using system.web.ui.webcontrols; using system.web.ui.webcontrols.webparts; using system.web.ui.htmlcontrols; using system.data.oledb; public partial class default2 : system.web.ui.page { protected void page_load(object sender, eventargs e) { } [system.web.services.webmethodattribute(), system.web.script.services.scriptmethodattribute()] public static string getdynamiccontent(string contextkey) { string selresult; selresult = " "; string datapath = httpcontext.current.server.mappath( "~/app_data/result.mdb "); string strexsit = "select count(*) as icount from dataset where swdjb_basic_004 like '%% " + contextkey.tostring() + "%% ' "; string streconnection = "provider=microsoft.jet.oledb.4.0;data source= " + datapath; oledbconnection econnection = new oledbconnection(streconnection); oledbcommand ecommand = new oledbcommand(strexsit, econnection); econnection.open(); oledbdatareader ereader = ecommand.EXECutereader(); ereader.read(); string count = ereader[ "icount "].tostring(); ereader.close(); econnection.close(); if (count == "0 ") { selresult = " <font style= 'color: #ff0033; '> 未找到与您输入关键字相关的纪录! </font> "; } else { selresult = " "; string strselect = "select swdjb_basic_001,swdjb_basic_004 from dataset where swdjb_basic_004 like '%% " + contextkey.tostring() + "%% ' "; string strsconnection = "provider=microsoft.jet.oledb.4.0;data source= " + datapath; oledbconnection sconnection = new oledbconnection(strsconnection); oledbcommand scommand = new oledbcommand(strselect, sconnection); sconnection.open(); oledbdatareader sreader = scommand.EXECutereader(); sreader.read(); //有问题部分就在下面 while (sreader.read()) { string midstr; midstr = string.format( " <span onclick=alert(\ 'nihao\ ');> {0} </span> <br /> ", sreader[ "swdjb_basic_004 "].tostring()); //midstr = " <a onclick=\ "alert(\ 'nihao\ ');\ "> " + sreader[ "swdjb_basic_004 "].tostring() + " </a> " + " <br /> "; selresult = selresult + midstr; //string midstr; //midstr = " <a onclick=\ "alert( 'nihao ');\ "> " + sreader[ "swdjb_basic_004 "].tostring() + " </a> " + " <br /> "; //selresult = selresult + midstr; } sreader.close(); sconnection.close(); } return selresult; } } aspx <%@ page language= "c# " autoeventwireup= "true " codefile= "default.aspx.cs " inherits= "default2 " %> <%@ register assembly= "ajaxcontroltoolkit " namespace= "ajaxcontroltoolkit " tagprefix= "cc1 " %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en " "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd "> <html xmlns= "http://www.w3.org/1999/xhtml " > <head runat= "server "> <title> 无标题页 </title> <link href= "stylesheet.css " rel= "stylesheet " type= "text/css " /> </head> <body style= "text-align: center "> <form id= "form1 " runat= "server "> <div style= "text-align: center "> <asp:scriptmanager id= "scriptmanager1 " runat= "server "> </asp:scriptmanager> <script type= "text/javascript "> function pushinput() { var seachobj = document.getelementbyid( 'txtinput ') var seachvalue = seachobj.value; if( seachvalue == " " ) { alert( "搜索关键字不能为空! "); return false; } var behavior=$find( 'dpe '); if(behavior) { behavior.populate(seachvalue); } } </script> <input id= "txtinput " type= "text " /> <br /> <input id= "btnok " type= "button " value= "确定 " onclick= "pushinput(); " /> <input id= "btnres " type= "reset " value= "清空 " /> <asp:panel id= "showresult " runat= "server " height= "174px " width= "240px " cssclass= "dpenormal " > </asp:panel> <cc1:dynamicpopulateextender id= "dpe " runat= "server " servicemethod= "getdynamiccontent " updatingcssclass= "dpeupdating " targetcontrolid= "showresult "> </cc1:dynamicpopulateextender> </div> </form> </body> </html> | | |
|