System.Web.HttpServerUtility.HtmlEncode C# (CSharp) Method

HtmlEncode() public method

public HtmlEncode ( string s ) : string
s string
return string
		public string HtmlEncode (string s)
		{
			return HttpUtility.HtmlEncode (s);
		}

Same methods

HttpServerUtility::HtmlEncode ( string s, TextWriter output ) : void

Usage Example

        public static string[] GetConnectionExcel(HttpPostedFile HttpFileUpload,HttpServerUtility ServerHU)
        {
            string[] strExcelConn = new string[2];
             string strFileName = ServerHU.HtmlEncode(HttpFileUpload.FileName);
             string strExtension = Path.GetExtension(strFileName);

             if (strExtension != ".xls" && strExtension != ".xlsx")
             {
            return strExcelConn;
             }

             string strUploadFileName = "~/UploadFiles/" + DateTime.Now.ToString("yyyyMMddHHmmss") + strExtension;
             strExcelConn[1] = strUploadFileName;
             HttpFileUpload.SaveAs(ServerHU.MapPath(strUploadFileName));

             //if (strExtension == ".xls")
             //   strExcelConn[0] = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ServerHU.MapPath(strUploadFileName) + ";Extended Properties='Excel 8.0;HDR=YES;'";
             //else
            strExcelConn[0] = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ServerHU.MapPath(strUploadFileName) + ";Extended Properties='Excel 12.0 Xml;HDR=YES;'";

             return strExcelConn;
        }
All Usage Examples Of System.Web.HttpServerUtility::HtmlEncode