To download files using a “Save As” dialog box try this code: Select Case FileExt Case “gif” ContentType = “image/gif” Case “tif” ContentType = “image/tiff” Case “jpg” ContentType = “image/jpeg” Case “pdf” ContentType = “application/pdf” Case “avi” ContentType = “video/x-msvideo” Case “mp3” ContentType = “audio/mpeg” Case “mpg” ContentType = “video/mpeg” Case “wav” ContentType = “audio/wav” Case “rar” ContentType = “application/x-rar-compressed” Case “zip” ContentType = “application/x-zip-compressed” Case […]
matt
SelectedValue which is invalid because it does not exist in the list of items
To populate drop down lists I bind the list to a lookup table in the database (i.e. States). Occasional the parent table (i.e. Customers) has a value that is “not on the list” and this error is genreated: ‘ddlState’ has a SelectedValue which is invalid because it does not exist in the list of items. […]
C# Fill a Dropdown List and For Loop
Here is a quick syntax for a For loop and filling a dropdown list with an incrementing number using C#. for (Int16 i = 1; i <= iMax; i++) { ListItem item = new ListItem(i.ToString()); ; ddlNumber.Items.Add(item); }
Force SSL ON or OFF Function
When working on a site that may have some pages in SSL (the check out pages) and most pages not I use a function to switch between SSL and Non SSL pages. First, I set the non secure and SSL URL’s in the config file under appSettings: <add key=”SSLURL” value=”https://www.mydomain.com”/> <add key=”NonSSLURL” value=”http://www.mydomain.com”/> Next, in […]
JavaScript Code To Toggle Check Boxes
Here is some JavaScript code to toggle check boxes (same action as radio buttons). In the page load event register the JavaScript: chkTwoYear.Attributes.Add(“onclick”, “javascript: CheckTwoProgram(” + chkTwoYear.ClientID + “);”); chkFourYear.Attributes.Add(“onclick”, “javascript: CheckFourProgram(” + chkFourYear.ClientID + “);”); In the HTML of the page add the JavaScript: <SCRIPT Language=”JavaScript”><!– function CheckTwoProgram(id) { if(id.checked) document.forms[0].chkFourYear.checked=false; } function CheckFourProgram(id) { if(id.checked) document.forms[0].chkTwoYear.checked=false; } //–> </SCRIPT>
Keyword Seach Phrase Counter
To find out how often a keyword or phrase is used try handy tool: https://adwords.google.com/KeywordPlanner
SPF Record
SPF is Sender Policy Framework. This is a tool to help fight spam by validating the from address of emails. When an email is received by an email server the sending domain can be checked for proper origination. Here is a sample rule in DNS: v=spf1 ip4:67.169.211.46 mx ptr -all Here is a tool to validate the […]
Testing Iframe Code
Testing Iframe code:
CSS Page Break with IE 7
To force a page break when printing the style=”page-break-before: always;” can be added. But this doesn’t always work with IE 7. For some reason IE 7 would ignore this. Probably because of the new print preview and “size to fit”. The simple fix to get IE 7 to recognize the page break just add something to […]
Email Encoder
When putting email addresses on a web page it is recommended to encode them. There are many web crawlers scanning pages to harvest email addresses. Here is an easy to use tool to encode the email address. http://www.wbwip.com/wbw/emailencoder.html