几个常用判断



        
protected string AppPath(HttpRequest req)
        {
            
string path = string.Empty;
            
try
            {
                path 
= req.ApplicationPath != "/"
                    
? req.ApplicationPath + "/"
                    : req.ApplicationPath;

            }
            
catch (Exception e)
            {
                
throw e;
            }
            
return path;
        }





        
protected string UrlPrefix(HttpRequest req)
        {
            
string path = "http://"
                            
+ req.Url.Host.ToString();

            path 
+= req.ApplicationPath != "/"
                    
? req.ApplicationPath + "/"
                    : req.ApplicationPath;
            
return path;
        }


/*
         * <%# Eval("数据字段") %>  中Eval方法有两次重载
         *     Eval(string expression)  返回为object
         *     Eval(string expression,string format) 返回为string
         
*/
        
public string GetLen(string str, int length)
        {
            
if (str != null && str != string.Empty)
                str 
= str.Length > length
                    
? str.Substring(0, length) : str;
            
else
                str 
= string.Empty;
            
return str;

        }

posted on 2007-08-31 15:03  Neo0820  阅读(180)  评论(0编辑  收藏  举报

导航