转载请表明:http://blog.youkuaiyun.com/jiangsq12345
一:为什么VS2010测试时,url中会自动生成一串奇怪的字符?
运行:localhost/myclass.aspx
回车后:localhost/(sviecu555gar4v55ogmacsfg)/myclass.aspx
答:这是ASP.Net记录Session的方式。如果客户端关闭了Cookies,则Session标识记录在URL位置。
可以通过去除web.config 配置文件中关于 Cookieless=true 的配置
二、用kindeditor把内容保存到数据后,如何将数据库中html代码显示到页面中?
答:
.aspx页加入
<div id="divBody" runat="server"></div>
然后在.cs页中加入
divBody.InnerHtml ="你要显示的html代码";
三、用Button控件时,onclick的页面重定向无法执行
答:因为Button 控件的类型是submit,所以本来就带有一个页面的重定向动作(本页刷新),所以会产出一个冲突。
<asp:Button ID="Btn_Send" runat="server" Text="发送" onclick="MsgSend_Click" />
解决办法是用 HTML的Input代替Button控件
<div ID="Btn_Send" runat="server" Text="发送" onclick="MsgSend_Click" />
四、将HTML代码保存到本地word文档中
//调用此方法导出为word文档,传入参数为this.Page
public static void getWordFile(String msgName,String msg_content, System.Web.UI.Page Page)
{
HttpResponse resp = Page.Response;
resp.Clear();
resp.Buffer = true;
resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
resp.AddHeader("Content-disposition", "attachment; filename=" + msgName);
resp.ContentType = "application/msword";
msg_content = "<html xmlns='http://www.w3.org/1999/xhtml'>" + msg_content + "</html>";
resp.Write(msg_content);
resp.End();
}
其中,msg_content 为要输出的html代码
五、在调用MS Word组件来转换word 到 pdf格式时,出现
【4317 无法嵌入互操作类型“Microsoft.Office.Interop.Word.ApplicationClass”。请改用适用的接口。】 错误
- 解决办法:
- 在Visual Studio 中点击菜单项“视图->解决方案资源管理器”,在其中点开“引用”文件夹,在"Microsoft.Office.Interop.Word" 上点击鼠标右键,选择“属性”,将属性中的“嵌入互操作类型”的值改为“false”即可。
六、HTML代码生成PDF文件的免费解决方案
参考我的另一篇博文 http://blog.youkuaiyun.com/jiangsq12345/article/details/7615974
七、从Excel导入数据到 SQL Server
第一步是点击开始并选择【运行】, 然后输入DTSWIZARD,然后安提示一步步操作即可。
八、客户端url显示不变,但是页面重新导向
方法是在服务器端将返回的页面内容从另一个页面上获取,用
Server.Tansfer( "other.aspx ");
九、前端输入内容验证
只允许中文的正则表达式:\u4e00-\u9fa5
十、前端等待提交时的等待界面
<div id="runing" runat="server" style="z-index: 12000; left: 0px; width: 100%; cursor: wait;position: absolute; top: 0px; height: 100%; visibility:hidden">
<table width="100%" height="100%">
<tr align="center" valign="middle">
<td>
<table width="200" height="120" bgcolor="Gray"
style="filter: Alpha(Opacity=70); color:White">
<tr align="center" valign="middle" >
<td>
<div id="Clocktimes"></div><br>
正在搜索<br>
请稍候....
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>