1. 在首行的声明中加入Debug="true",这样在程序编译的时候如果有错误,会定位在出错行,而不是报给你一大堆错误代码,不过这个会在出错的时候自动提示给你
2. asp.net出错:找不到可安装的 ISAM ,绝大多数情况是数据连接语句的问题,看看是不是把data source写成了date source或是语句的其他地方少了,错了什么
3. 编译时如果出现error BC30009,提示说少了什么资源,可是我们明明已经在代码中有相应的导入语句,但问题其实不在这里,我们需要在命令行的编译语句里使用/r:加入相应的资源
4.一段C#中用来转化网页中特殊字符的代码:
public string strRep(string oldStr)
{
string newStr = oldStr.Replace("<", "<");
newStr = newStr.Replace(">", ">");
newStr = newStr.Replace("\r\n","<br>");
newStr = newStr.Replace(" ", " ");
return newStr;
}
5.一段动改变title内容的代码:
<%@ Page Language="c#" Explicit="true" Strict="true" %>
<script language="c#" runat="Server">
private void Page_Load(object sender, EventArgs e)
{
//Put user code to initialize the page here
litTitle.Text = "This is my page title.";
}
</script>
<html>
<head>
<title><asp:Literal id="litTitle" runat="server"></asp:Literal></title>
</head>
<body>
<form id="Form1" method="post" runat="server">
</form>
</body>
</html>
<script language="c#" runat="Server">
private void Page_Load(object sender, EventArgs e)
{
//Put user code to initialize the page here
litTitle.Text = "This is my page title.";
}
</script>
<html>
<head>
<title><asp:Literal id="litTitle" runat="server"></asp:Literal></title>
</head>
<body>
<form id="Form1" method="post" runat="server">
</form>
</body>
</html>