Monday, December 22, 2008

Write C Program using Visual Studio .net

Please see below link to write a Hello World application in C using visual studio
http://support.microsoft.com/kb/829488

Friday, October 31, 2008

Force a website to use WWW using IIS

Some times you need to redirect all request to http://example.com/ to http://www.example.com/ . To achieve this you can write code to see if request is for http://example.com/ and redirect to http://www.example.com/ . We can also achieve this using just IIS (i think it will be faster than Code base solution) taking advantage of host headers. Add hostheader http://www.example.com/ to your website (see how to this in this link http://www.visualwin.com/host-header/ ) . Now create another new website with exact same settings as your first website exept host header value it should be example.com. Now right click your new website in IIS select properites and goto Home directory tab. select "A redirection to URL" radio button, in the "Redirect to" text box enter http://www.example.com/ . See the screen shot below for more details

Monday, September 29, 2008

Embedding Javascript file in custom control

  1. Add javascript file to your project
  2. Set Build Action of this file Embeded Resource
  3. Add the following entry into your AssemblyInfo.cs
    [assembly: WebResource("YourNameSpace.Filename.js", "text/javascript")]
  4. Add following code in your OnInit event

    string webresourceURL = Page.ClientScript.GetWebResourceUrl(this.GetType(), "YourNameSpace.Filename.js");
    this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "cctextbox",webresourceURL);
  5. Please remember YourNameSpace is base name space in your project