Skip to main content

Posts

Showing posts from 2008

How to download file using C#

Download to specified path: System.Net.WebClient client = new System.Net.WebClient(); client.DownloadFile(strURL, strLocalPath); Download without specified path: //strFile: your physical file path in server FileInfo fInfo = new FileInfo(strFile); Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + fInfo.Name); Response.AddHeader("Content-Length", fInfo.Length.ToString()); Response.ContentType = "application/octet-stream"; Response.WriteFile(fInfo.FullName);

How to select file by using ASP.NET

How to open file dialog in ASP.NET? We need two controls, one TextBox named txtFile and one Button named btnBrowse. Add the following code in Page_Load const string fiName = "fileBrowse"; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<div style='visibility: hidden; width: 0px; height: 0px'>"); sb.Append(string.Format("<input type=file id='{0}' accept='image/gif,image/jpeg'></div>", fiName)); sb.Append("<Script language=JavaScript> function BrowseClick(){"); sb.Append(String.Format("document.forms[0]['{0}'].click();", fiName)); sb.Append(String.Format("document.forms[0]['{0}'].value = document.forms[0]['{1}'].value;", txtFile.ClientID, fiName)); sb.Append("return false;} </Script>"); RegisterClientScriptBlock("scriptKey", sb.ToString()); btnBrowse.Attributes.Add(...

How to get current page name in ASP.NET

You can use the following code to get current page name in your application written by ASP.NET string GetCurrentPageName() { string sPath = System.Web.HttpContext.Current.Request.Url.AbsolutePath; System.IO.FileInfo oInfo = new System.IO.FileInfo(sPath); string sRet = oInfo.Name; return sRet; }

Oracle Product Codes

ABM - Activity Based Management AD - Applications DBA AHL - Oracle Advanced Service Online AHM - Oracle Hosting Manager AK - Oracle Common Modules-AK ALR - Oracle Alert AMF - Oracle Fulfillment Services AMS - Oracle Marketing AMV - Oracle MarketView AN - Oracle Sales Analysis AP - Oracle Payables AR - Oracle Receivables AS - Oracle Sales ASF - Oracle Field Sales ASG - Oracle CRM Gateway for Mobile Services ASL - Oracle Mobile Field Sales Laptop ASO - Oracle Order Capture ASP - Oracle Field Sales/PalmTM Devices AST - TeleSales AU - Application Utilities AX - Global Accounting Engine AZ - Application Implementation BEN - Oracle Advanced Benefits BIC - Customer Intelligence BIL - Sales Intelligence BIM - Marketing Intelligence BIS - Oracle Applications BIS BIV - Oracle Service Intelligence BIX - Call Center Intelligence BNE - Oracle Web ADI BOM - Oracle Bills of Material BSC - Balanced Scorecard CCT - Oracle Call Center and Telephony CE - Oracle Cash Management CHV - Oracle Supplier Sched...

toProperCase with Javascript

Javasript does not support toProperCase function in String object. So, someone has written a simple code like that: function toProperCase(s) { return s.toLowerCase().replace(/^(.)|\s(.)/g, function ($1) { return $1.toUpperCase(); }); } For more information, go to this link http://www.codeproject.com/KB/scripting/propercase.aspx

How to get Active Directory attributes

When coding with Active Directory, you may need to know its attributes about account name, first name, last name, etc. In this case, you can refer to this link http://support.microsoft.com/default.aspx/kb/555638 If you want to know more detail, I think you can download a free software LDAP Browser in this address http://www.openldap.org

How to get screen size with Javasript

Get screen width and height by using Javascript: var screenW = 800, screenH = 600; if (parseInt(navigator.appVersion)>3) { screenW = screen.width; screenH = screen.height; } else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)== 3 && navigator.javaEnabled()) { var jToolkit = java.awt.Toolkit.getDefaultToolkit(); var jScreenSize = jToolkit.getScreenSize(); screenW = jScreenSize.width; screenH = jScreenSize.height; }

Set data to DropDownList

Your website contains a lot of DropDownList in several pages. To save times, you can put the following code into the App_Code and call when needed. public void SetDataToDropDown(DropDownList drdn, int iValue) { for (int i = 0; i { if (drdn.Items[i].Value == iValue.ToString()) { drdn.SelectedIndex = i; break; } } }

How to get parameter values in query string by Javascript

Sometimes, you want to get the parameter value in query string by using Javascript. In this case, you can use this function to do that: function GetParamValue(strParamName) { var strReturn = ""; var strHref = window.location.href; if ( strHref.indexOf("?") > -1 ) { var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase(); var aQueryString = strQueryString.split("&"); for ( var iParam = 0; iParam { if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ) { var aParam = aQueryString[iParam].split("="); strReturn = aParam[1]; break; } } } return unescape(strReturn); } For example, if your URL like that: www.example.com\ProductDetail.aspx?ProductID=3 You can call: var strProductID = GetParamValue("ProductID");