Month: May 2009

  • WordPress 中文标签 Tag 解决方法一则(2.71)

    WordPress中文的问题真的很多,固定链接是一个。移植时候又碰到了个标签Tag的问题,英文Tag一切正常,中文就显示NOT FOUND。发现问题主要为IIS对URL截取的时候取得的是GBK的编码,但是我们的主题只要有中文都用的UTF-8的编码,所以我们要对编码进行处理后在交给数据库进行查询。 解决方法:使用PHP内置函数 mb_convert_encoding()进行UTF-8到GBK转换。 1、打开wp-includes\classes.php文件; 2、查找将 $pathinfo = $_SERVER['PATH_INFO']; $req_uri = $_SERVER['REQUEST_URI']; 分别修改成: $pathinfo = mb_convert_encoding($_SERVER['PATH_INFO'], "UTF-8", "GBK"); $req_uri = mb_convert_encoding($_SERVER['REQUEST_URI'], "UTF-8", "GBK"); 我的2.71的classes.php文件分别修改了行153和行158处。 if ( isset($_SERVER['PATH_INFO']) ) $pathinfo = mb_convert_encoding($_SERVER['PATH_INFO'], "UTF-8", "GBK"); else $pathinfo = ''; $pathinfo_array = explode('?', $pathinfo); $pathinfo = str_replace("%", "%25", $pathinfo_array[0]); $req_uri = mb_convert_encoding($_SERVER['REQUEST_URI'], "UTF-8", "GBK");

  • GridView vs DataGrid

    dotNet 2.0后,M$推荐使用GridView取代DataGrid(Comparing the GridView and DataGrid Web Server Controls)。在做Testlink测试Case的Chart,然后想在表中插入HTML format的时候出现了奇怪的问题。DataGrid一切正常,GridView貌似对直接插入的HTML进行了encode,HTML原始显示了出来。 狂搜一遍, protected void gvTP_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[1].Text = Server.HtmlDecode(e.Row.Cells[1].Text); } } 这下加入的HTML format就不会给encode咯。

  • GridView mouseover 的高亮

    由于dotnet中获得到的RowStyle中color为System.Drawing.Color类的,所以首先需要将其转换成HTML能够接受的#xxxxxx形式。写了一个函数: string toWebColor(System.Drawing.Color theColor) { if (Convert.ToString(theColor.R, 16) == "0" && Convert.ToString(theColor.G, 16) == "0" && Convert.ToString(theColor.B, 16) == "0") { return "#ffffff"; } else { return "#" + Convert.ToString(theColor.R, 16) + Convert.ToString(theColor.G, 16) + Convert.ToString(theColor.B, 16); } } 下边的程序就是个间隔行设置Attribute的行为: if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.RowState == DataControlRowState.Normal) { e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='orange'"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='" +…

  • GridView vs DataGrid, Server.HtmlDecode()

    dotNet 2.0后,M$开始推荐使用GridView取代DataGrid(Comparing the GridView and DataGrid Web Server Controls)。前些天在做Testlink测试Case的Chart,然后想在表中插入HTML format的时候出现了奇怪的问题。DataGrid一切正常,GridView貌似对直接插入的HTML进行了encode,HTML被原原本本地显示了出来。 在MSDN上找到Server类下边有个HTML解码的方法Server.HtmlDecode(),题外话还有个Server.HtmlEncode()的方法。 protected void gvTestPlan_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[1].Text = Server.HtmlDecode(e.Row.Cells[1].Text); } } 这下加入的HTML format就不会给encode了。