locked
Mobile web page and tables RRS feed

  • Question

  • User-2056656471 posted

     Hello, How can I use dynamic generated table on ASP NET mobile web page? I have data from database and I need at least three columns. Most new mobilephone browsers (standard xhtml-mobile10) support tables. I can use <table> tags between  <mobile:DeviceSpecific>  tag, but I 'd like to generate dynamic table, so I need something like Response.Write("<table>"). Unfortunately it doesn't work. :( . Please HELP!! (sorry Imy english isn't perfect)

    Monday, August 11, 2008 3:13 PM

Answers

  • User-1113931457 posted

    i can give you an example that works fine on most of the phones but its not in mobile web form.

    the idea is, replace the pages that your are going to use dynamically generated controls (like table here) with basic xhtml pages. display will reamin same but the page form is different.

    like if your page is Mobile.aspx refer it with xMobile.aspx and make the page as your requirements. 

     

    xMobile.aspx

    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="xMobile.aspx.cs" Inherits="xMobile" ContentType="text/html" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Dynamic Table</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <% CreateTable(); %>
        </div>
        </form>
    </body>
    </html>

     

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

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

        }
        public void CreateTable()  /// create your table dynamically here
        {
            Response.Write("<table><tr>"); /// single row data
            for (int i = 0; i < 3; i++)
            {
                Response.Write("<td>");
                Response.Write("Column No: " + (i + 1) ); /// Column data
                Response.Write("</td>");
            }
            Response.Write("</tr></table><br />");
        }
    }

     and don't forget to use ContentType="text/html" on the page directives.

    hope it will help...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 11, 2008 9:56 PM

All replies

  • User-1113931457 posted

    i can give you an example that works fine on most of the phones but its not in mobile web form.

    the idea is, replace the pages that your are going to use dynamically generated controls (like table here) with basic xhtml pages. display will reamin same but the page form is different.

    like if your page is Mobile.aspx refer it with xMobile.aspx and make the page as your requirements. 

     

    xMobile.aspx

    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="xMobile.aspx.cs" Inherits="xMobile" ContentType="text/html" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Dynamic Table</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <% CreateTable(); %>
        </div>
        </form>
    </body>
    </html>

     

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

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

        }
        public void CreateTable()  /// create your table dynamically here
        {
            Response.Write("<table><tr>"); /// single row data
            for (int i = 0; i < 3; i++)
            {
                Response.Write("<td>");
                Response.Write("Column No: " + (i + 1) ); /// Column data
                Response.Write("</td>");
            }
            Response.Write("</tr></table><br />");
        }
    }

     and don't forget to use ContentType="text/html" on the page directives.

    hope it will help...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 11, 2008 9:56 PM
  • User-2056656471 posted

    Thanks very much, It's good solution, but I have anather. I think that define my own Mobile Web User Control will fix the problem. Next I can use <%= > tags to run script.

     But I have another problem. How to create user control to show html  text after  using DataBind() function. When I use <%=> It always run when page_load, but I want later.
     

    Tuesday, August 12, 2008 2:05 AM