.net技术注意

1.fckeditor 脚本出现unterminated string literal问题的时候,一般就是遇到付给value值有换行情况。  

 一般对此处理要使用替换方式:return content.Replace("'", "&#39").Replace("'", "&#34").Replace("\r","\\");

或者直接在控件里赋值

注意:单引号,双引号,换行符号。换行不是转换\n,而是转换\r

2.回转 url ReturnUrl=<%= HttpUtility.UrlEncode(Request.Url.AbsoluteUri) %>,在url后面加上这个,然后跳转

<input type="button" value="返回" onclick='javascript:location.href="<%=!string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]) ? Request.QueryString["ReturnUrl"] : "/Manage/Consult/BlogDataList-1.aspx"%>";return false;' />

 string url = Request.QueryString["ReturnUrl"];
                        url = !string.IsNullOrEmpty(url) ? url : serviceList;
                        Response.Redirect(url);

 <a style="cursor:pointer;" onclick='history.back(-1);'>提交订单资料</a>

这样写返回之后不会去掉原来的数据

3.主从显示

<asp:Repeater ID="Repeater1" runat="server">
        <ItemTemplate>
            <tr class="c1">
                <td><%#Eval("sort") %></td>
                <td><a href="http://www.cnblogs.com/shtml/view_cls1/ViewCls_<%#Eval("id") %>.shtml" target="_blank"><%#Eval("cls_name") %></a> <a href="./admin_cls2_add.aspx?alt=1&id=<%#Eval("id") %>">[添加二级分类]</a></td>
                <td><asp:Button ID="Button1" runat="server" Text="生成" CssClass="btn" CommandName='<%#Eval("id") %>' OnCommand="cls1Shtml" /></td>
                <td><asp:Button ID="Button2" runat="server" Text="编辑" CssClass="btn" CommandName='<%#Eval("id") %>' OnCommand="cls1Edit" /></td>
                <td><asp:Button ID="Button3" runat="server" Text="删除" CssClass="btn" CommandName='<%#Eval("id") %>' OnCommand="cls1Delete" OnClientClick="return confirm('确定删除吗?')" /></td>
            </tr>
                <asp:Repeater ID="Repeater2" runat="server" datasource='<%# ((DataRowView)Container.DataItem).Row.GetChildRows("TwoTable") %>'>
                <!--DataSource='<%#Eval("TwoTable") %>'直接这样也是可以的-->
                <ItemTemplate>
                   
                <tr class="c2" onmouseover="className='tdover2'" onmouseout="className='tdout2'">
                    <td>&nbsp;&nbsp;<%#Eval("[\"sort\"]")%></td>
                    <td class="c2_1"><a href='http://www.cnblogs.com/shtml/view_cls2/ViewCls2_<%#Eval("[\"id\"]")%>_0.shtml' target="_blank">二级分类: <%#Eval("[\"cls_name\"]")%></a></td>
                    <td><a href="#">生成</a></td>
                    <td><a href="./admin_cls2_add.aspx?alt=2&id=<%#Eval("[\"id\"]")%>">编辑</a></td>
                    <td><asp:LinkButton ID="delete" CommandName='<%#Eval("[\"id\"]")%>' OnCommand="cls2Delete" OnClientClick="return confirm('确定删除吗?')" runat="server">删除</asp:LinkButton></td>
                </tr>
                </ItemTemplate>
                </asp:Repeater>
        </ItemTemplate>
    </asp:Repeater>

后台代码

DataSet Ds = new DataSet();
            Ds.Tables.Add(Pn163.com_BLL.BLL_cls1.cls1DataSet().Tables[0].Copy());
            Ds.Tables.Add(Pn163.com_BLL.BLL_cls2.cls2DataSet().Tables[0].Copy());
            Ds.Relations.Add("TwoTable",Ds.Tables["cls1"].Columns["id"], Ds.Tables["cls2"].Columns["cls1_code"]);
            Telesa.DataBind.ToBind(Repeater1, Ds);

4.四舍五入

/// <summary>
        /// 四舍五入归整
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        public static string Round(decimal d)
        {
            return string.Format("{0:0}", d);
        }
        /// <summary>
        /// 四舍五入后返回(单位分)
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        public static decimal RoundPayment(decimal d)
        {
            decimal yuan = d / 100;
            //decimal fen = d;
            decimal fen = Convert.ToDecimal(Round(yuan)) * 100;
            return fen;
        }

5.获取重写后的路径

string url=Request.FilePath;
或者
string url=Request.RawUrl;

用这个试试
Request.Url.AbsoluteUri

6.ftp配置路径(使用Ser-U)

访问的时候直接输入ftp://127.0.0.1 然后输入用户名与密码再导航到指定目录

7.判断是否为ie

1.+[1,]

2.!+"v1"

3.!!(window.attachEvent && navigator.userAgent.indexOf('Opera') === -1)

4.!!(!window.addEventListener&& navigator.userAgent.indexOf('Opera') === -1)

5.!!(document.all && navigator.userAgent.indexOf('Opera') === -1)

转码。。。。System.Web.HttpUntitly.UrlEncode("你的字符串",Encoding.GetEncoding("gb2312"))

7.ashx中使用session
public class TeacherInfoHandler : IHttpHandler, IReadOnlySessionState,一定要继承IReadOnlySessionState,而且不需要实现

你可能感兴趣的:(.net)