Attach Sina image carousel to Asp.net

Source: Internet
Author: User
<Div class = "pic_news"> <Div id = "focusviwer" align = "center"> <embed id = "focusflash" width = "320" Height = "225" flashvars = '<% = Full %> 'wmode = "Opaque" menu = "false" allowScriptAccess = "samedomain" Quality = "high" bgcolor = "# f5f5f5" name = "focusflash" src = "images/flash1.swf" type = "application/X-Shockwave-flash"> </div> <SCRIPT type = "text/JavaScript" charset = "GBK"> <! -- Var focus_width = 318 var focus_height = 218 var text_height = 25 var swf_height = focus_height + text_height var pics = '<% = picurl %> '; vaR links = '<% = links %>'; links = links. replace (/. $/, ""); var texts = '<% = text %>'; var focusflash = new sinaflash ("images/flash1", "focusflash", focus_width, swf_height, "7", "# f5f5f5", false, "high"); focusflash. addparam ("allowScriptAccess", "samedomain "); Focusflash. addparam ("menu", "false"); focusflash. addparam ("wmode", "Opaque"); focusflash. addvariable ("pics", PICs); focusflash. addvariable ("Links", links); focusflash. addvariable ("texts", texts); focusflash. addvariable ("borderwidth", focus_width); focusflash. addvariable ("borderheight", focus_height); focusflash. addvariable ("textheight", text_height); focusflash. write ("focusviwer"); // --> </SCRIPT> </Div> oracledm dm = new oracledm (); Public String links = ""; // hyperlink Public String picurl = ""; // image path Public String text = ""; // text Public String full = ""; // full path protected void page_load (Object sender, eventargs e) {If (! Ispostback) {rptzgg (); // notification announcement rpxwlb (); // News list rpqxsl (); // District/County Water Conservancy rpztbd (); // Special Report rpfxkh (); // Flood Control and Drought Relief rpszjc (); // shuizheng monitoring showimg (); // generate picture reports} // homepage Picture News Public void showimg () {string sqlstr = "select ID, title, l_content from (select * From t_leastclass where type = 'image Report') Where rownum <= 5"; datatable DTP = DM. getsql (sqlstr ). tables [0]; string strtitle = ""; // splicing title string picurl = ""; // image title string link = ""; // Hyperlink for (INT I = 0; I <DTP. rows. count; I ++) {strtitle + = DTP. rows [I] ["title"]. tostring (). length> 20? DTP. rows [I] ["title"]. tostring (). substring (0, 20) + "... ": DTP. rows [I] ["title"]. tostring () + "|"; picurl + = getimageurl (DTP. rows [I] ["l_content"]. tostring () + "|"; Link + = "lashgc. aspx? Id = "+ DTP. rows [I] ["ID"]. tostring () + "|";} strtitle = strtitle. trimend ('|'); picurl = picurl. trimend ('|'); link = link. trimend ('|'); Links = link; picurl = picurl; text = strtitle; full = "pics =" + picurl + "& links =" + Links + "& texts =" + TEXT + "& borderwidth = 320 & borderheight = 198 & textheight = 26 ";} /// <summary> /// obtain the desired image address from the string /// </Summary> /// <Param name = "Source"> string </param> /// <returns> required </Returns> Public String getimageurl (string source) {arraylist list = new arraylist (); string result = ""; string Pattern = "] *? \ SSRC = ['\ "]? (.*?) ['\ "]. *?> "; RegEx Reg = new RegEx (pattern); matchcollection MC = reg. matches (source); foreach (Match m in MC) {list. add (M. groups [1]. value);} If (list. count> 0) {string S = list [0]. tostring (). trimstart ('/'); Result = S. substring (S. indexof ('/') + 1);} else {result = "images/nopic.jpg";} return result ;}# endregion

Focus: use regular expressions to obtain the image path in a string

]*?\\ssrc=['\"]?(.*?)['\"].*?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.