Let me start by saying I'm new to asp and any help would be greatly appreciated.
I'm developing a mobile site for my company. Ideally I would like to detect the users browser and if its a handheld device change the the master page to a mobile friendly version. I've come up with this browser detection script and placed it in the Page_Load event of the codebehind page:
string strUserAgent = Request.UserAgent.ToString().ToLower();
if (strUserAgent != null)
{
if (Request.Browser.IsMobileDevice == true ||
strUserAgent.Contains("iphone") ||
strUserAgent.Contains ("blackberry") ||
strUserAgent.Contains("mobile") ||
strUserAgent.Contains("windows ce") ||
strUserAgent.Contains("opera mini") ||
strUserAgent.Contains("palm"))
{
Response.Redirect("DefaultMobile.aspx");
}
}
Currently the script redirects to DefaultMobile.aspx....is there any way to change the master page instead?
I tried using:
this.MasterPageFile = "~/mobile/DefaultMobile.master";
...but no luck
Thanks in Advance!