<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="HomePage" %>
Home Page
File: Default.aspx.cs
using System;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Reflection;
using System.IO;
public partial class HomePage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string HOMEPAGE = "http://www.rntsoft.com";
HttpBrowserCapabilities caps = Request.Browser;
if (caps.IsBrowser("IE") && (caps.MajorVersion > 5 ||
caps.MajorVersion == 5 && caps.MinorVersion >= 5))
{
HomePageButton.Disabled = false;
HomePageButton.Attributes["onclick"] = "SetHomePage(this)";
Type t = this.GetType();
if (!Page.ClientScript.IsClientScriptBlockRegistered(t, "SetHomePage"))
{
string js = BuildScriptCode(HOMEPAGE);
Page.ClientScript.RegisterClientScriptBlock(t, "SetHomePage", js, true);
}
}
else
HomePageButton.Disabled = true;
}
private string BuildScriptCode(string url)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("function SetHomePage(obj) {");
sb.AppendLine(" obj.style.behavior=\"url(#default#homepage)\";");
sb.AppendFormat(" obj.setHomePage(\"{0}\");\r\n", url);
sb.AppendLine("}");
return sb.ToString();
}
}