ASP.NET Forums 2.0 本地化修改(一)
该集的内容主要收集于网上,一些原来的出处地址和作者没有找到,只能对原作者说抱歉了,如作者看到需要注明的,请和我联系。
一、使论坛支持中文用户名
其实这个问题只要了解原理的话,很容易就可以解决,对用户名的限制主要是通过正则表达式来控制。相关文件为各skin目录下的Skin-CreateNewAccount.ascx和Skin-CreateNewAccount2.ascx。下面直接贴出修改方法:
查找这一行:
![](/Images/OutliningIndicators/None.gif)
ControlToValidate="Username" ValidationExpression="[a-zA-Z]+[^<>]*" Cssclass="validationWarning">*</asp:RegularExpressionValidator>
替换为这一行(已修改,原来的代码由于blog编辑器的问题,自动过滤了一些字符):
<asp:RegularExpressionValidator EnableClientScript="false" ID="usernameRegExValidator" runat="server" ControlToValidate="Username" ValidationExpression="[^0-9|^\<\>\,\.\~\`\!\@\#\$\%\^\&\*\(\)_\+\-\=\\\|\[\]\{\}\:\;\?\']+[^\<\>\,\.\~\`\!\@\#\$\%\^\&\*\(\)_\+\-\=\\\|\[\]\{\}\:\;\?\']*" Cssclass="validationWarning">*</asp:RegularExpressionValidator>
二、如果附件为图片,那么直接显示该附件
影响的文件:Controls项目下的PostDisplay/TextPost.cs文件;
方法一(直接显示):
修改TextPost.cs文件的InitializeSkin(Control skin)方法,代码如下:
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
|| Extension==".png" || Extension==".bmp")
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
方法二:
把方法一中的body.Text +=改成:
![](/Images/OutliningIndicators/None.gif)
并且在ShowPost.aspx文件中增加下列js代码:
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
注意:图片高和宽 分别是560*428,你可以改成其他的大小
下集主题预告:
如何将论坛附件直接以文件形式保存,并读取照片文件的Exif信息;