Showing posts from November, 2013

return a file, c#,

string filename = "myfile.typ" ; string fileStr = "" ; System.Text. UTF8Encoding encoding = new System.Text. UTF8Encoding (); byte [] bytes = encoding.GetBytes(fileStr); //or any other way to serialize your file Response.Clear(); Response.ContentType = "application/ics;charset=utf-8" ; //the general rule is (1) google (2) application/fileType (3) if is text then text/fileType Response.AddHeader( "content-disposition" , "inline;filename=" + filename); Response.BinaryWrite(bytes); Response.End(); Response.Flush();

usefull CSS tricks and tips

1. Style a Dropdown / Select: 2. Style Checkboxes and Radio: the point is to hide the inputs and put spans with background images instead and use js to change the background-position at need.

Costumize Facebook, Twitter ad Google Plus Sharing

Facebook : beyond the great api they give for extra stuff they are the only ones still allowing title, description and image via href so the code is like this function OpenFacebookShare(title, summary, url, imageUrl) {   var url = '[title]=' +         encodeURIComponent(title) +     '&p[summary]=' + encodeURIComponent(summary) +     '&p[url]=' + encodeURIComponent(url) +     '&p[images][0]=' + encodeURIComponent(imageUrl);,  'mywindow' , 'menubar=1,resizable=1,width=650,height=450' ); }; as simple as that. Twitter: twitter only allows url and text (only 140 chars) by href. but they do request the url for their own meta tags, i.e. "twitter:title" ect. to do this you must create a twitter account and create a "card" for your domain and allow that domain. its really not that much of a horror, just create an account, go her

Xml to Excel Via Xsl

there is a nice trick in XSL that allows us to Create XLS documents. therefor taking any object, serializing it to XML and then using the right XSL we will get our XLS just as we want it, so there is the XSL. notice that if you serialize objects that comes from services the usually come with some [System.Xml.Serialization. XmlTypeAttribute (Namespace= "http://xmlns.bla/bla/yourType" )] and if so the XML nodes will look like this < node  xmlns = " http://xmlns.bla/bla/yourType " > 20:52:00 </ node > and for some reason it wont read the nodes, so the solution is allXmlStr = allXmlStr.Replace( "xmlns=\" http://xmlns.bla/bla/yourType \"" , "" ); < xsl:stylesheet version = " 1.0 "  xmlns = " urn:schemas-microsoft-com:office:spreadsheet "  xmlns:xsl = " "  xmlns:msxsl = " urn:schemas-microsoft-com:xslt "  xmlns:user = " urn:my-scri