Question : How to include dynamic html code in aspx page?

There is a web application used to let mobile users to browse the website through iphone, htc, samsung safari, mobile IE mobile browsers.

Since different mobile OS embedded with different mobile browsers and even on the same device, there are more than one mobile browser.

In the aspx page, there is

Inside it, it includes metatag, external js and css files.

I can detect the mobile browser by user-agent. For different mobile agent, I need to load different css, metatag and js into the aspx

The checking of user-agent runs on VC# server side.

How can I load different segment of code into aspx page?

Do I need to use xslt?

Please advise.



Answer : How to include dynamic html code in aspx page?

you can do that but then you will have to read from that file.

default.aspx:
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

http://www.w3.org/1999/xhtml">

   
<% if (Request.UserAgent == "MOBILE_PHONE_BROWSER1") { %>
  <%=readFromFile(@"c:\asdf.txt") %>
<% } else { %>
  <%=readFromFile(@"c:\asdf.txt") %>
<% } %>



   
   

   
   

   






default.aspx.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;


public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public string readFromFile(string file)
    {
        TextReader tr = new StreamReader(file);
        string ret = tr.ReadToEnd();
        tr.Close();
        return ret;
    }
}
Random Solutions  
 
programming4us programming4us