Geeks With Blogs
Sharvan Dhaka blog Tricky Solution/ Code
Read Response of a web request in a byte Array with C# Asp.net
this code snippet read the respone fo a web request through binary reader private byte[] getByte(string URL) { HttpWebRequest wrGETURL = (HttpWebRequest)WebRequest.... System.Net.HttpWebResponse webresponse = (HttpWebResponse)wrGETURL.G... string ct = webresponse.ContentType; Stream objStream = webresponse.GetResponseStre... BinaryReader breader = new BinaryReader(objStream); byte[] buffer = breader .ReadBytes((int)webresponse... return buffer; } ......

Posted On Sunday, October 15, 2006 5:57 PM

Force a page to download a file c# asp.net
string Id= "0"; try { this.EnableViewState = false; Response.ContentType = "text/.txt"; string Filename = System.Web.HttpContext.Curr... Filename = Filename + Id + ".txt"; Response.WriteFile(Filename); // Response.Write("string"); string strFilename = Id + ".txt"; Response.Buffer = true; Response.AddHeader("Content... "attachment; filename=" + ID+".txt"); } catch (Exception ex) { Response.Write(ex.ToString()); } Response.End(); ......

Posted On Sunday, October 15, 2006 5:56 PM

Create .VCF File(outlook contact file) with C#
This is code of to create vcf card on the fly //sdBuild is string builder sdBuild.Append("N:" + strCn + System.Environment.NewLine); sdBuild.Append("FN:" + strCn +System.Environment.NewLine); //// encoding to base 64 certString64 = certString64 + System.Environment.NewLine + "KEY;X509;ENCODING=BASE64:" + System.Environment.NewLine; certString64 = certString64 + Convert.ToBase64String((byt... + System.Environment.NewLine; //// encoding to base 64 ends here sdBuild.Append(certString64); sdBuild.Append(System.Envir... ......

Posted On Sunday, October 15, 2006 5:55 PM

How to change the ower of tables in Microsoft SQL Server database
To do this, execute the following command on every table exec sp_changeobjectowner '?????', 'DBO' - where ????? is the name of your database table. Also below is the stored procedure through which you can change the owner for every table in the database. EXEC sp_changeobjectowner @oldownerplusobject, @new create procedure _ChangeObjectOwner (@type varchar(1),@old varchar(20),@new varchar(20)) as declare @ObjectName varchar(100) declare @oldownerplusobject varchar(50) begin declare Cursor_Object cursor ......

Posted On Sunday, October 15, 2006 5:55 PM

How to change the ower of tables in Microsoft SQL Server database
To do this, execute the following command on every table exec sp_changeobjectowner '?????', 'DBO' - where ????? is the name of your database table. Also below is the stored procedure through which you can change the owner for every table in the database. EXEC sp_changeobjectowner @oldownerplusobject, @new create procedure _ChangeObjectOwner (@type varchar(1),@old varchar(20),@new varchar(20)) as declare @ObjectName varchar(100) declare @oldownerplusobject varchar(50) begin declare Cursor_Object cursor ......

Posted On Sunday, October 15, 2006 5:54 PM

Clear Project List from Start Page
Here is a nice tips to clear the Recent project list or File list from Visual Studio .Net
Run--> RegEdit and navigate to

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\\ProjectMRUList delete unnecessary list.

similarly for FileMRuList.

Make sure not disturb other key from the registry.

Posted On Sunday, October 15, 2006 5:51 PM

How to get the HTML name attribute of ASP.Net Control c# as.net
//Function to get the HTML name of the server control from the Client Id // Parameters: // clientId - Control.ClientId // serverId - Control.id private string GetHTMLNameById(string clientId, string serverId) { int pos = serverId.IndexOf('_'); string HTMLName = ""; if(pos >= 0) { pos = clientId.IndexOf(serverId); HTMLName = clientId.Remove(pos, serverId.Length); HTMLName = HTMLName.Replace('_', '$'); HTMLName += serverId; } else HTMLName = clientId.Replace('_', '$'); return HTMLName; } ......

Posted On Sunday, October 15, 2006 5:49 PM

Serialize & Deserialize c# asp.net
Serialize (convert an object instance to an XML document): // Assuming obj is an instance of an object XmlSerializer ser = new XmlSerializer(obj.GetType()); System.Text.StringBuilder sb = new System.Text.StringBuilder(); System.IO.StringWriter writer = new System.IO.StringWriter(sb); ser.Serialize(writer, obj); XmlDocument doc = new XmlDocument(); doc.LoadXml(sb.ToString()); Deserialize (convert an XML document into an object instance): //Assuming doc is an XML document containing a serialized object ......

Posted On Sunday, October 15, 2006 5:43 PM

How to convert a string to a byte array and convert a byte array to a string c# asp.net
Convert a string to a byte array string myString = "a test string"; byte[] myByteArray = new byte[myString.Length]; int i = 0; foreach(char c in InStr.ToCharArray()) { myByteArray [i] = (byte)c; i++; } Convert a byte array to a string System.Text.Encoding enc = System.Text.Encoding.ASCII; byte[] myByteArray = enc.GetBytes("a text string); string myString = enc.GetString(myByteArray ); ......

Posted On Sunday, October 15, 2006 5:42 PM

Copyright © Sharvan Dhaka | Powered by: GeeksWithBlogs.net