Geeks With Blogs
Gaurav Taneja Great dreams... never even get out of the box. It takes an uncommon amount of guts to put your dreams on the line, to hold them up and say, "How good or how bad am I?" That's where courage comes in. September 2006 Entries
Downloading the content
try { this.EnableViewState = false; Response.ContentType = "text/xml"; // chnage the content type accordingly string Filename = System.Web.HttpContext.Curr... Filename = “abc.txt“; Response.WriteFile(Filename); string strFilename =“abc.txt"; Response.Buffer = true; Response.AddHeader("Content... "attachment; filename=" + strFilename); } catch (Exception ex) { Response.Write(ex.ToString()); } Response.End(); ......

Posted On Saturday, September 30, 2006 4:56 AM

Serialize & Deserialize + C#
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 Saturday, September 30, 2006 4:27 AM

How to convert a string to a byte array and convert a byte array to a string + C#
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;... myByteArray = enc.GetBytes("a text string);string myString = enc.GetString(myByteArray ); ......

Posted On Saturday, September 30, 2006 4:18 AM

Lightweight Directory Access Protocol (LDAP)
In computer networking, the Lightweight Directory Access Protocol, or LDAP ("ell-dap"), is a networking protocol for querying and modifying directory services running over TCP/IP. An LDAP directory usually follows the X.500 model: it is a tree of entries, each of which consists of a set of named attributes with values. While some services use a more complicated "forest" model, the vast majority use a simple starting point for their database organization. An LDAP directory often reflects various political, ......

Posted On Saturday, September 30, 2006 4:02 AM

Setting Default focus on TextBox & Button for ASP.NET 2.0
You need to define which Textbox and Button you want to make them default. // add the attribute in your form tag <form id="form1" DefaultButton="Button1" DefaultFocus="TextBox2" runat="server"> ......

Posted On Tuesday, September 5, 2006 9:39 AM

How to Execute Javascript on Server Control for ASP.NET 2.0
//// Code Snippet <form id="form1" runat="server"> <div> <h3>To Exceute Client Click Event</h3> <asp:Button ID="Button1" OnClientClick='javascript:a... Just Clicked ME!")' OnClick="Button1_Click" Text="Click Me!" runat="server" /> </div> </form> ......

Posted On Tuesday, September 5, 2006 9:32 AM

How to get the HTML name attribute of ASP.Net Control
//Function to get the HTML name of the server control from the Client Id // Parameters: // clientId - Control.ClientId // serverId - 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 Monday, September 4, 2006 10:00 AM

Copyright © Gaurav Taneja | Powered by: