5分钟让你了解VB.NET生成静态页面和分页原理
创始人
2024-06-09 19:31:05
0

程序员有的时候为一些小的问题而烦恼,在这里帮大家解决一个关于VB.NET生成静态页面和分页原理的分析,下面就来看代码:

1、VB.NET生成静态页面和分页原理静态页面template.html,主要是定义了一些特殊字符,用来被替换。

  1.  
  2.  
  3.  
  4. $Title</< SPAN>title> <LI class=""></< SPAN>head> <LI class=alt><body> <LI class=""><div style="width: 417px; height: 54px" align="center"> <LI class=alt><br /> <LI class="">$Title</< SPAN>div> <LI class=alt><div style="width: 417px; height: 8px"> <LI class="">浏览<font color="red"><script src="http://localhost/.Net/NewsFiles/ClickCount.aspx?NewsId=$NewsId"></< SPAN>script></< SPAN>font>次  $Time</< SPAN>div> <LI class=alt><div style="width: 417px; height: 100px"> <LI class="">$Content</< SPAN>div> <LI class=alt><div style="width: 416px; height: 9px"> <LI class="">$Pager</< SPAN>div> <LI class=alt><div style="width: 416px; height: 8px"> <LI class=""><form id="form1" action="../AddComment.aspx" style="margin:0px"> <LI class=alt><input id="Text1" type="text" /><Img id="Image1" src="../../UserInfo/CheckCode.aspx"/><br /> <LI class=""><textarea  id="CommentContent" cols="20" rows="2"></< SPAN>textarea> <LI class=alt><br /> <LI class=""><input id="NewsId" type="hidden" value="$NewsId"/> <LI class=alt><input id="Button1" type="submit" value="button" /> <LI class=""><a href="../Display.aspx?NewsId=$NewsId">查看更多评论</< SPAN>a></< SPAN>form> <LI class=alt></< SPAN>div> <LI class=""></< SPAN>body> <LI class=alt></< SPAN>html> </LI></OL></PRE> <P><STRONG>2、VB.NET生成静态页面和分页原理分析前态页面 NewsAdd.aspx,就是一个表单,用来填写新闻的标题和内容。</STRONG></P><PRE><OL class=dp-xml><LI class=alt><STRONG><FONT color=#006699><</FONT></STRONG>%...@ Page <FONT color=#ff0000>Language</FONT>=<FONT color=#0000ff>"C#"</FONT> <FONT color=#ff0000>AutoEventWireup</FONT>=<FONT color=#0000ff>"false"</FONT> <FONT color=#ff0000>validateRequest</FONT>=<FONT color=#0000ff>"false"</FONT> <FONT color=#ff0000>CodeFile</FONT>=<FONT color=#0000ff>"NewsAdd.aspx.cs"</FONT> <FONT color=#ff0000>Inherits</FONT>=<FONT color=#0000ff>"NewsAdd.Admin_AdminPanel_NewsAdd"</FONT> %<STRONG><FONT color=#006699>></FONT></STRONG> <LI class=""><STRONG><FONT color=#006699><</FONT></STRONG>%...@ Register <FONT color=#ff0000>TagPrefix</FONT>=<FONT color=#0000ff>"FCKeditorV2"</FONT> <FONT color=#ff0000>Namespace</FONT>=<FONT color=#0000ff>"FredCK.FCKeditorV2"</FONT> <FONT color=#ff0000>Assembly</FONT>=<FONT color=#0000ff>"FredCK.FCKeditorV2"</FONT> %<STRONG><FONT color=#006699>></FONT></STRONG> <LI class=alt><STRONG><FONT color=#006699>></FONT></STRONG> <LI class=""><STRONG><FONT color=#006699><html</FONT></STRONG> <FONT color=#ff0000>xmlns</FONT>=<FONT color=#0000ff>"http://www.w3.org/1999/xhtml"</FONT> <STRONG><FONT color=#006699>></FONT></STRONG> <LI class=alt><STRONG><FONT color=#006699><head</FONT></STRONG> <FONT color=#ff0000>runat</FONT>=<FONT color=#0000ff>"server"</FONT><STRONG><FONT color=#006699>></FONT></STRONG> <LI class=""><STRONG><FONT color=#006699><title></FONT></STRONG>添加新闻<STRONG><FONT color=#006699></< SPAN>title></FONT></STRONG> <LI class=alt><STRONG><FONT color=#006699></< SPAN>head></FONT></STRONG> <LI class=""><STRONG><FONT color=#006699><body></FONT></STRONG> <LI class=alt><STRONG><FONT color=#006699><form</FONT></STRONG> <FONT color=#ff0000>id</FONT>=<FONT color=#0000ff>"form1"</FONT> <FONT color=#ff0000>runat</FONT>=<FONT color=#0000ff>"server"</FONT><STRONG><FONT color=#006699>></FONT></STRONG> <LI class=""><STRONG><FONT color=#006699><div></FONT></STRONG> <LI class=alt><STRONG><FONT color=#006699><asp:Label</FONT></STRONG> <FONT color=#ff0000>ID</FONT>=<FONT color=#0000ff>"Label2"</FONT> <FONT color=#ff0000>runat</FONT>=<FONT color=#0000ff>"server"</FONT> <FONT color=#ff0000>Text</FONT>=<FONT color=#0000ff>"标题"</FONT><STRONG><FONT color=#006699>></< SPAN>asp:Label></FONT></STRONG> <LI class=""><STRONG><FONT color=#006699><asp:TextBox</FONT></STRONG> <FONT color=#ff0000>ID</FONT>=<FONT color=#0000ff>"Title"</FONT> <FONT color=#ff0000>runat</FONT>=<FONT color=#0000ff>"server"</FONT> <FONT color=#ff0000>Width</FONT>=<FONT color=#0000ff>"325px"</FONT><STRONG><FONT color=#006699>></< SPAN>asp:TextBox><br</FONT></STRONG> <STRONG><FONT color=#006699>/></FONT></STRONG> <LI class=alt><STRONG><FONT color=#006699><asp:Label</FONT></STRONG> <FONT color=#ff0000>ID</FONT>=<FONT color=#0000ff>"Label1"</FONT> <FONT color=#ff0000>runat</FONT>=<FONT color=#0000ff>"server"</FONT> <FONT color=#ff0000>Text</FONT>=<FONT color=#0000ff>"内容"</FONT><STRONG><FONT color=#006699>></< SPAN>asp:Label></FONT></STRONG> <LI class=""><STRONG><FONT color=#006699><FCKeditorV2:FCKeditor</FONT></STRONG> <FONT color=#ff0000>id</FONT>=<FONT color=#0000ff>"Content"</FONT> <FONT color=#ff0000>basePath</FONT>=<FONT color=#0000ff>"~/FCKeditor/"</FONT>  <FONT color=#ff0000>runat</FONT>=<FONT color=#0000ff>"server"</FONT> <FONT color=#ff0000>Height</FONT>=<FONT color=#0000ff>"400px"</FONT> <FONT color=#ff0000>Width</FONT>=<FONT color=#0000ff>"70%"</FONT><STRONG><FONT color=#006699>></< SPAN>FCKeditorV2:FCKeditor></FONT></STRONG> <LI class=alt><STRONG><FONT color=#006699><asp:Button</FONT></STRONG> <FONT color=#ff0000>ID</FONT>=<FONT color=#0000ff>"Button1"</FONT> <FONT color=#ff0000>runat</FONT>=<FONT color=#0000ff>"server"</FONT> <FONT color=#ff0000>OnClick</FONT>=<FONT color=#0000ff>"Button1_Click"</FONT> <FONT color=#ff0000>Text</FONT>=<FONT color=#0000ff>"Button"</FONT> <STRONG><FONT color=#006699>/></FONT></STRONG> <LI class=""><STRONG><FONT color=#006699><asp:Label</FONT></STRONG> <FONT color=#ff0000>ID</FONT>=<FONT color=#0000ff>"Message"</FONT> <FONT color=#ff0000>runat</FONT>=<FONT color=#0000ff>"server"</FONT> <STRONG><FONT color=#006699>></< SPAN>asp:Label></< SPAN>div></FONT></STRONG> <LI class=alt><STRONG><FONT color=#006699></< SPAN>form></FONT></STRONG> <LI class=""><STRONG><FONT color=#006699></< SPAN>body></FONT></STRONG> <LI class=alt><STRONG><FONT color=#006699></< SPAN>html></FONT></STRONG> </LI></OL></PRE> <P><STRONG>3、VB.NET生成静态页面和分页原理后台页面 NewsAdd.aspx.cs</STRONG> </P><PRE><OL class=dp-xml><LI class=alt>using System;  <LI class="">using System.Data;  <LI class=alt>using System.Configuration;  <LI class="">using System.Collections;  <LI class=alt>using System.Web;  <LI class="">using System.Web.Security;  <LI class=alt>using System.Web.UI;  <LI class="">using System.Web.UI.WebControls;  <LI class=alt>using System.Web.UI.WebControls.WebParts;  <LI class="">using System.Web.UI.HtmlControls;  <LI class=alt>using Mysqlserver;  <LI class="">using System.IO;  <LI class=alt>using System.Text;  <LI class="">namespace NewsAdd  <LI class=alt>...{  <LI class="">public partial class Admin_AdminPanel_NewsAdd : System.Web.UI.Page  <LI class=alt>...{  <LI class="">protected void Page_Load(object sender, EventArgs e)  <LI class=alt>...{  <LI class="">}  <LI class=alt>protected void Button1_Click(object sender, EventArgs e)  <LI class="">...{  <LI class=alt>string <FONT color=#ff0000>strDate</FONT> = <FONT color=#0000ff>DateTime</FONT>.Now.ToString("yyMMdd") + "\" + DateTime.Now.ToString("yyyymmddhhmmss");  <LI class="">string <FONT color=#ff0000>strFileName</FONT> = <FONT color=#0000ff>strDate</FONT> + ".shtml";//存储到数据库中  <LI class=alt>string <FONT color=#ff0000>strTitle</FONT>=<FONT color=#0000ff>Request</FONT>.Form["Title"].ToString().Trim();//接收传过来的标题  <LI class="">string <FONT color=#ff0000>strContent</FONT>=<FONT color=#0000ff>Request</FONT>.Form["Content"].ToString().Trim();//接收传过来的内容  <LI class=alt>string[] <FONT color=#ff0000>content</FONT> = <FONT color=#0000ff>strContent</FONT>.Split(new Char[] ...{'|'});//对内容进行拆分,并保存到数组  <LI class="">int <FONT color=#ff0000>upbound</FONT> = <FONT color=#0000ff>content</FONT>.Length;//数组的上限  <LI class=alt>SqlServerDataBase <FONT color=#ff0000>db</FONT> = <FONT color=#0000ff>new</FONT> SqlServerDataBase();  <LI class="">bool <FONT color=#ff0000>success</FONT> = <FONT color=#0000ff>db</FONT>.Insert("insert into inNews(Title,Content,FilePath)values('" + strTitle + "','" + strContent + "','" + strFileName + "')", null);  <LI class=alt>//if (success)  <LI class="">   // <FONT color=#ff0000>Message.Text</FONT> = <FONT color=#0000ff>"添加成功!"</FONT>;  <LI class=alt>/**////////////////////////////创建当前日期的文件夹开始  <LI class="">string <FONT color=#ff0000>dir</FONT> = <FONT color=#0000ff>Server</FONT>.MapPath("../../"+"NewsFiles/"+DateTime.Now.ToString("yyMMdd"));//用来生成文件夹  <LI class=alt>if (!Directory.Exists(dir))  <LI class="">...{  <LI class=alt>Directory.CreateDirectory(dir);  <LI class="">} </LI></OL></PRE> <P>【编辑推荐】</P> <OL> <LI><FONT color=#0000ff>VB.NET获取硬盘信息四大法宝</FONT></LI> <LI><FONT color=#0000ff>讲述VB.NET调用Excel的好处</FONT></LI> <LI><FONT color=#0000ff>简单例子概述VB.NET新窗体</FONT></LI> <LI><FONT color=#0000ff>描述VB.NET工程转换成步骤</FONT></LI> <LI><FONT color=#0000ff>自己动手实现VB.NET控件数组</FONT></LI></OL> <!--end::Text--> </div> <!--end::Description--> <div class="mt-5"> <!--关键词搜索--> </div> <div class="mt-5"> <p class="fc-show-prev-next"> <strong>上一篇:</strong><a href="/chengxu/24312.html">自己动手改写VB.NET内存指针</a><br> </p> <p class="fc-show-prev-next"> <strong>下一篇:</strong><a href="/chengxu/24314.html">Windows Server 2008下细粒度口令策略的实现</a> </p> </div> <!--begin::Block--> <div class="d-flex flex-stack mb-2 mt-10"> <!--begin::Title--> <h3 class="text-dark fs-5 fw-bold text-gray-800">相关内容</h3> <!--end::Title--> </div> <div class="separator separator-dashed mb-9"></div> <!--end::Block--> <div class="row g-10"> </div> </div> <!--end::Table widget 14--> </div> <!--end::Col--> <!--begin::Col--> <div class="col-xl-4 mt-0"> <!--begin::Chart Widget 35--> <div class="card card-flush h-md-100"> <!--begin::Header--> <div class="card-header pt-5 "> <!--begin::Title--> <h3 class="card-title align-items-start flex-column"> <!--begin::Statistics--> <div class="d-flex align-items-center mb-2"> <!--begin::Currency--> <span class="fs-5 fw-bold text-gray-800 ">热门资讯</span> <!--end::Currency--> </div> <!--end::Statistics--> </h3> <!--end::Title--> </div> <!--end::Header--> <!--begin::Body--> <div class="card-body pt-3"> <!--begin::Item--> <div class="d-flex flex-stack mb-7"> <!--begin::Symbol--> <div class="symbol symbol-60px symbol-2by3 me-4"> <div class="symbol-label" style="background-image: url('/static/assets/images/nopic.gif')"></div> </div> <!--end::Symbol--> <!--begin::Title--> <div class="m-0"> <a href="/chengxu/241137.html" class="text-dark fw-bold text-hover-primary fs-6">如何允许远程连接到MySQL数...</a> <span class="text-gray-600 fw-semibold d-block pt-1 fs-7">[[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...</span> </div> <!--end::Title--> </div> <!--begin::Item--> <div class="d-flex flex-stack mb-7"> <!--begin::Symbol--> <div class="symbol symbol-60px symbol-2by3 me-4"> <div class="symbol-label" style="background-image: url('/static/assets/images/nopic.gif')"></div> </div> <!--end::Symbol--> <!--begin::Title--> <div class="m-0"> <a href="/chengxu/61017.html" class="text-dark fw-bold text-hover-primary fs-6">如何利用交换机和端口设置来管理...</a> <span class="text-gray-600 fw-semibold d-block pt-1 fs-7">在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...</span> </div> <!--end::Title--> </div> <!--begin::Item--> <div class="d-flex flex-stack mb-7"> <!--begin::Symbol--> <div class="symbol symbol-60px symbol-2by3 me-4"> <div class="symbol-label" style="background-image: url('/static/assets/images/nopic.gif')"></div> </div> <!--end::Symbol--> <!--begin::Title--> <div class="m-0"> <a href="/chengxu/119031.html" class="text-dark fw-bold text-hover-primary fs-6">施耐德电气数据中心整体解决方案...</a> <span class="text-gray-600 fw-semibold d-block pt-1 fs-7">近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...</span> </div> <!--end::Title--> </div> <!--begin::Item--> <div class="d-flex flex-stack mb-7"> <!--begin::Symbol--> <div class="symbol symbol-60px symbol-2by3 me-4"> <div class="symbol-label" style="background-image: url('https://files.pic99.top/shayuweb/202409/eb2e03366045d9f.jpg')"></div> </div> <!--end::Symbol--> <!--begin::Title--> <div class="m-0"> <a href="/chengxu/139440.html" class="text-dark fw-bold text-hover-primary fs-6">20个非常棒的扁平设计免费资源</a> <span class="text-gray-600 fw-semibold d-block pt-1 fs-7">Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...</span> </div> <!--end::Title--> </div> <!--begin::Item--> <div class="d-flex flex-stack mb-7"> <!--begin::Symbol--> <div class="symbol symbol-60px symbol-2by3 me-4"> <div class="symbol-label" style="background-image: url('/static/assets/images/nopic.gif')"></div> </div> <!--end::Symbol--> <!--begin::Title--> <div class="m-0"> <a href="/chengxu/27164.html" class="text-dark fw-bold text-hover-primary fs-6">2009 IBM动态架构新动力...</a> <span class="text-gray-600 fw-semibold d-block pt-1 fs-7"></span> </div> <!--end::Title--> </div> <!--begin::Item--> <div class="d-flex flex-stack mb-7"> <!--begin::Symbol--> <div class="symbol symbol-60px symbol-2by3 me-4"> <div class="symbol-label" style="background-image: url('/static/assets/images/nopic.gif')"></div> </div> <!--end::Symbol--> <!--begin::Title--> <div class="m-0"> <a href="/chengxu/225.html" class="text-dark fw-bold text-hover-primary fs-6">通过 XML 进行内容发布</a> <span class="text-gray-600 fw-semibold d-block pt-1 fs-7"></span> </div> <!--end::Title--> </div> <!--begin::Item--> <div class="d-flex flex-stack mb-7"> <!--begin::Symbol--> <div class="symbol symbol-60px symbol-2by3 me-4"> <div class="symbol-label" style="background-image: url('/static/assets/images/nopic.gif')"></div> </div> <!--end::Symbol--> <!--begin::Title--> <div class="m-0"> <a href="/chengxu/130901.html" class="text-dark fw-bold text-hover-primary fs-6">德国电信门户网站可实时显示全球...</a> <span class="text-gray-600 fw-semibold d-block pt-1 fs-7">德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...</span> </div> <!--end::Title--> </div> <!--begin::Item--> <div class="d-flex flex-stack mb-7"> <!--begin::Symbol--> <div class="symbol symbol-60px symbol-2by3 me-4"> <div class="symbol-label" style="background-image: url('https://files.pic99.top/shayuweb/202503/5fe82cca6c5ff78.jpg')"></div> </div> <!--end::Symbol--> <!--begin::Title--> <div class="m-0"> <a href="/chengxu/246646.html" class="text-dark fw-bold text-hover-primary fs-6">为啥国人偏爱 Mybatis,...</a> <span class="text-gray-600 fw-semibold d-block pt-1 fs-7">关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...</span> </div> <!--end::Title--> </div> <!--begin::Item--> <div class="d-flex flex-stack mb-7"> <!--begin::Symbol--> <div class="symbol symbol-60px symbol-2by3 me-4"> <div class="symbol-label" style="background-image: url('https://files.pic99.top/shayuweb/202407/404021d01b8347f.jpg')"></div> </div> <!--end::Symbol--> <!--begin::Title--> <div class="m-0"> <a href="/chengxu/48727.html" class="text-dark fw-bold text-hover-primary fs-6">《非诚勿扰》红人闫凤娇被曝厕所...</a> <span class="text-gray-600 fw-semibold d-block pt-1 fs-7">【51CTO.com 综合消息360安全专家提醒说,“闫凤娇”、“非诚勿扰”已经被黑客盯上成为了“木...</span> </div> <!--end::Title--> </div> <!--begin::Item--> <div class="d-flex flex-stack mb-7"> <!--begin::Symbol--> <div class="symbol symbol-60px symbol-2by3 me-4"> <div class="symbol-label" style="background-image: url('/static/assets/images/nopic.gif')"></div> </div> <!--end::Symbol--> <!--begin::Title--> <div class="m-0"> <a href="/chengxu/133934.html" class="text-dark fw-bold text-hover-primary fs-6">2012年第四季度互联网状况报...</a> <span class="text-gray-600 fw-semibold d-block pt-1 fs-7">[[71653]]  北京时间4月25日消息,据国外媒体报道,全球知名的云平台公司Akamai Te...</span> </div> <!--end::Title--> </div> </div> <!--end::Body--> </div> <!--end::Chart Widget 35--> </div> <!--end::Col--> </div> </div> <!--end::Content container--> </div> <!--end::Content--> </div> <!--end::Content wrapper--> <!--begin::Footer--> <div id="kt_app_footer" class="app-footer"> <!--begin::Footer container--> <div class="app-container container-xxl d-flex flex-column flex-md-row flex-center flex-md-stack py-3"> <!--begin::Copyright--> <div class="text-dark order-2 order-md-1"> <span class="text-muted fw-semibold me-1">2025 ©</span> <a href="/" target="_blank" class="text-gray-800 text-hover-primary">鲨鱼网</a> <a href="https://beian.miit.gov.cn/" target="_blank" class="text-gray-800 text-hover-primary"></a> <a href="http://spbjmm.com.shayuweb.com">上品网</a><a href="http://www.zzszq.net/">深知网</a><a href="http://www.taiyangwa.net/">太阳生活网</a><a href="http://baike.taiyangwa.net/">太阳百科网</a><a href="http://ypkjmy.com.shayuweb.com/">一品科技</a><a href="http://www.yuansudz.com/news/">元素网</a><a href="http://www.xn--i6qw12a.com/">帛典网</a><a href="http://xldmm.com.shayuweb.com/">星链岛</a> </div> <!--end::Copyright--> <!--begin::Menu--> <ul class="menu menu-gray-600 menu-hover-primary fw-semibold order-1"> <li class="menu-item"> <a href="/news/" target="_blank" class="menu-link px-2">科技资讯</a> </li> <li class="menu-item"> <a href="/chengxu/" target="_blank" class="menu-link px-2">程序开发</a> </li> <li class="menu-item"> <a href="/sitemap.xml" target="_blank" class="menu-link px-2">sitemap</a> </li> </ul> <!--end::Menu--> </div> <!--end::Footer container--> </div> <!--end::Footer--> </div> <!--end:::Main--> </div> <!--end::Wrapper--> </div> <!--end::Page--> </div> <!--end::App--> <div id="kt_scrolltop" class="scrolltop" data-kt-scrolltop="true"> <!--begin::Svg Icon | path: icons/duotune/arrows/arr066.svg--> <span class="svg-icon"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect opacity="0.5" x="13" y="6" width="13" height="2" rx="1" transform="rotate(90 13 6)" fill="currentColor"></rect> <path d="M12.5657 8.56569L16.75 12.75C17.1642 13.1642 17.8358 13.1642 18.25 12.75C18.6642 12.3358 18.6642 11.6642 18.25 11.25L12.7071 5.70711C12.3166 5.31658 11.6834 5.31658 11.2929 5.70711L5.75 11.25C5.33579 11.6642 5.33579 12.3358 5.75 12.75C6.16421 13.1642 6.83579 13.1642 7.25 12.75L11.4343 8.56569C11.7467 8.25327 12.2533 8.25327 12.5657 8.56569Z" fill="currentColor"></path> </svg> </span> <!--end::Svg Icon--> </div> <!--begin::Javascript--> <script>var hostUrl = "/static/default/pc/";</script> <!--begin::Global Javascript Bundle(mandatory for all pages)--> <script src="/static/default/pc/plugins/global/plugins.bundle.js"></script> <script src="/static/default/pc/js/scripts.bundle.js"></script> <!--end::Global Javascript Bundle--> <!--end::Javascript--> </body> <!--end::Body--> </html>