.net 网站开发知识点一
2012-07-15 00:12
183 查看
一、form验证
网站 开发后台文件放在一个文件夹里,在URL中输入没有验证的页面不允许访问,我们采取form验证,在webConfig文件夹里的文件如下:
○ defaultUrl:定义在身份验证之后用于重定向的默认 URL。默认值为default.aspx ;
○ loginUrl:指定如果找不到任何有效的身份验证 Cookie,将请求重定向到的用于登录的 URL。默认值为login.aspx .
timeout cookie过期时间,单位是分钟
<authorization> 授权:顺序是先写allow,再写deny,不然就会出现问题。
allow :向授权规则映射添加一个规则,该规则允许对资源进行访问。
deny :向授权规则映射添加一条拒绝对资源的访问的授权规则。
这样访问Backstage文件夹里的文件都会先访问login.aspx
在后台添加代码
陈琪即用户名,User.Identity.Name可获取登录用户名
注销代码 FormsAuthentication.SignOut();
二、FCKediter控件的使用
本控件可以轻松更改界面,同时满足发布新闻的一些基本要求,加入图片和插入超链接,工具包可以在这下载工具包
文件夹放在根目录下,.dll则引用,工具箱内添加后将会有控件,在webConfig里配置后,直接引用即可,代码如下
BasePase:fckeditor所在目录,UserFilesPath:上传的图片所在目录,这里设置完,上传图片可能会报错
FCKeditor出现"this connector is disabled Please check the"editor/filemanager/connectors/aspx/config.aspx"
解决办法:
打开editor/filemanager/connectors/aspx/config.ascx修改CheckAuthentication()方法,返回true
fckeditor面板样式更改,在fckeditor文件夹里的,fckconfig.js文件里
添加到数据库时:
读取时后台读取,前台显示
三、分页控件的使用
此空间引入AspNetPager.dll,将控件拖入前台页面,为其设置样式,代码如下:
后台绑定代码:
网站 开发后台文件放在一个文件夹里,在URL中输入没有验证的页面不允许访问,我们采取form验证,在webConfig文件夹里的文件如下:
<?xml version="1.0"?> <configuration> <appSettings /> <connectionStrings /> <system.web> <compilation debug="true"> </compilation> <authentication mode="Forms"> <forms loginUrl="Backstage/Login.aspx" defaultUrl="Backstage/Default.aspx" timeout="1"></forms> </authentication> </system.web> <location path="Backstage"> <system.web> <authorization> <deny users="?"/> </authorization> </system.web> </location> </configuration>
○ defaultUrl:定义在身份验证之后用于重定向的默认 URL。默认值为default.aspx ;
○ loginUrl:指定如果找不到任何有效的身份验证 Cookie,将请求重定向到的用于登录的 URL。默认值为login.aspx .
timeout cookie过期时间,单位是分钟
<authorization> 授权:顺序是先写allow,再写deny,不然就会出现问题。
allow :向授权规则映射添加一个规则,该规则允许对资源进行访问。
deny :向授权规则映射添加一条拒绝对资源的访问的授权规则。
这样访问Backstage文件夹里的文件都会先访问login.aspx
在后台添加代码
FormsAuthentication.RedirectFromLoginPage("陈琪", false);
陈琪即用户名,User.Identity.Name可获取登录用户名
注销代码 FormsAuthentication.SignOut();
二、FCKediter控件的使用
本控件可以轻松更改界面,同时满足发布新闻的一些基本要求,加入图片和插入超链接,工具包可以在这下载工具包
文件夹放在根目录下,.dll则引用,工具箱内添加后将会有控件,在webConfig里配置后,直接引用即可,代码如下
<appSettings> <add key="FCKeditor:BasePath" value="~/fckeditor/"/> <add key="FCKeditor:UserFilesPath" value="~/upload/" /> </appSettings>
BasePase:fckeditor所在目录,UserFilesPath:上传的图片所在目录,这里设置完,上传图片可能会报错
FCKeditor出现"this connector is disabled Please check the"editor/filemanager/connectors/aspx/config.aspx"
解决办法:
打开editor/filemanager/connectors/aspx/config.ascx修改CheckAuthentication()方法,返回true
fckeditor面板样式更改,在fckeditor文件夹里的,fckconfig.js文件里
FCKConfig.ToolbarSets["Basic"] = [ ['Source', 'DocProps', '-', 'Save', 'NewPage', 'Preview', '-', 'Templates'], ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteWord', '-', 'Print', 'SpellCheck'], ['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'], ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'], '/', ['Bold', 'Italic', 'Underline', 'StrikeThrough', '-', 'Subscript', 'Superscript'], ['OrderedList', 'UnorderedList', '-', 'Outdent', 'Indent', 'Blockquote'], ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyFull'], ['Link', 'Unlink', 'Anchor'], ['Image', 'Flash', 'Table', 'Rule', 'Smiley', 'SpecialChar', 'PageBreak'], '/', ['Style', 'FontFormat', 'FontName', 'FontSize'], ['TextColor', 'BGColor'], ['FitWindow', 'ShowBlocks', '-', 'About'] // No comma for the last row. ]; FCKConfig.ToolbarSets["Default"] = [ ['Copy', 'PasteText', 'PasteWord', 'Bold', 'Italic', 'TextColor', 'BGColor', '-', 'OrderedList', 'UnorderedList'], ['Link', 'Unlink', 'Anchor'], ['Image', 'Flash', 'Table', 'Rule', 'Smiley', 'SpecialChar', 'PageBreak'], ['Style', 'FontFormat', 'FontName', 'FontSize'] ]; FCKConfig.EnterMode = 'p' ; // p | div | br FCKConfig.ShiftEnterMode = 'br' ; // p | div | br["Basic"]里就是具备的所有功能,["Default"]里就是面板上显示的功能,你可以根据需要修改,FCKConfig.EnterModer是文字面板中回车的作用,有3种可选。
添加到数据库时:
news.NewsText =FckEditor.Value.Trim();
读取时后台读取,前台显示
//新闻内容 public string NewsText { get; set; } this.NewsText = Regex.Replace(news.NewsText, "<br />", "<p>");前台直接调用即可:
<div style=" text-align:justify; width:550px; overflow:hidden "> <%=NewsText%> <br /><br /></td>
三、分页控件的使用
此空间引入AspNetPager.dll,将控件拖入前台页面,为其设置样式,代码如下:
<style type="text/css"> /* ASPnetBar淘宝风格 */ .paginator a {border:solid 1px #ccc;color:#0063dc;cursor:pointer;text-decoration:none;} .paginator a:visited {padding: 1px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;} .paginator a:hover {border:solid 1px #F50;color:#f60;text-decoration:none;} </style> <div style=" font-size:12px; text-align :center ; width:700px ;color:#0063dc; padding:5px" > <webdiyer:AspNetPager ID="AspNetPager" CssClass="paginator" runat="server" FirstPageText="首页" LastPageText="未页" NextPageText="下一页" PrevPageText="上一页" ShowPageIndexBox="Always" NumericButtonCount="5" CenterCurrentPageButton="True" HorizontalAlign="Center" Width="600px" onpagechanged="AspNetPager_PageChanged" AlwaysShow="True"> </webdiyer:AspNetPager> </div>
后台绑定代码:
/// <summary> /// GridView绑定全部数据 /// </summary> public void GridViewBind() { txtRowCount.Text = newsManage.ExecuteScalar().ToString(); AspNetPager.RecordCount = newsManage.ExecuteScalar();//数据访问层获得数据记录数 int intStart = AspNetPager.PageSize * (AspNetPager.CurrentPageIndex - 1); int intNum = AspNetPager.PageSize; DataGridView.DataSource = newsManage.GetList(intStart, intNum);//返回数据列表 DataGridView.DataBind(); } protected void AspNetPager_PageChanged(object sender, EventArgs e) { try { GridViewBind(); } catch (Exception ex) { throw ex; } }
相关文章推荐
- .net 网站开发知识点二
- .net开发人员经常浏览的8个网站
- Ubutu+Apache+Mono 实现.net开发的网站跨平台移植
- VC2005从开发MFC ActiveX ocx控件到发布到.net网站的全部过程
- ASP.NET 开发必备知识点(1):如何让Asp.net网站运行在自定义的Web服务器上
- .NET开发人员必知的八个网站
- .NET开发人员必知的八个网站
- .NET开发人员必知的八个网站
- VC2005从开发MFC ActiveX ocx控件到发布到.net网站的全部过程
- .NET开发人员必知的八个网站
- .NET开发人员必知的八个网站
- VC2005从开发MFC ActiveX ocx控件到发布到.net网站的全部过程
- .net网站开发(前端):4.MVC HtmlHelper
- .net开发人员经常浏览的8个网站
- PHP网站开发实例教程-知识点归纳1
- 微软放缓.NET动态语言开发计划,徐汇区网站设计
- 使用VS2008开发运行在.net 2.0环境下的 ASP.NET AJAX 网站
- VC2005从开发MFC ActiveX ocx控件到发布到.net网站的全部过程
- .NET开发人员必知的八个网站
- .NET网站开发的架构设计