通过C Sharp代码创建HTML表 [英] HTML table creation through c sharp code

查看:77
本文介绍了通过C Sharp代码创建HTML表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个ASP.NET网站,我在其中添加了一个单击删除按钮时触发的弹出窗口.该弹出窗口后面的代码是:在删除按钮上,单击数据库要求输入数据,到期日期"和名称".如果数据库中存在该数据,则会使用弹出窗口向用户显示此数据.

显示此弹出窗口
1)我在aspx页面上创建了"Datagrid"
2)我在程序中的aspx.cs上创建一个数据表.在数据表中添加了到期日期"和名称"列,并在此表中添加了数据格式数据库
3)在程序中的aspx.cs上创建一个数据源,并将数据表添加到此数据源.
4)datagrid.datasource =在步骤3)中创建的数据源

现在,在不同的浏览器中,我对该弹出窗口的外观有所不同.在mozilla中,我得到的是水平和垂直网格线,但是在表格中的任意位置也得到了一条深色的水平线.在IE中,我根本没有得到网格线.

由于我是通过C#代码创建此表的,因此无法对该表进行任何格式化. Somrone可以告诉我如何修复此表的外观并对其进行格式化吗?

I am currently developing an ASP.NET website where I have added one popup triggered on clicking a delete button. The code behind this popup is: on delete button click database is asked for data, ''Expiry date'' and ''name''. If that data is present in database then user is shown this data using popup.

To show this popup
1) I created ''Datagrid'' on aspx page
2) I create a datatable on aspx.cs in program. Added columns ''Expiry date'' and ''name'' to datatable and added data fom database to this table
3) Created one datasource on aspx.cs that is in program and added datatable to this datasource.
4) datagrid.datasource=datasource created in step 3)

Now in different browsers I am getting different looks of this popup. In mozilla I am getting horizontal and vertical gridlines, but also getting one dark horizontal line at random location in table. In IE I am not getting gridlines at all.

Since I am creating this table through C# code I can''t do any formatting on this table. Can somrone tell me how can I fix the appearance of this table and format it?

推荐答案

",因为我无法通过c清晰的代码创建此表该表的任何格式."

错误,是的,您可以.我建议您创建一个用于格式化显示的样式表(包含CSS).我要解决的方法是一次生成您的弹出窗口,然后将其保存到磁盘.

保存版本后,创建样式表并将其链接到保存的版本.现在,这是聪明"的一面;在Firefox和IE中将其打开,然后开始将样式添加到CSS中.定期刷新在两个浏览器中打开的页面,并检查添加的内容在两个浏览器中是否相同.

在Firefox中执行此操作的原因是,它比IE更符合标准,因此请确保首先使它在IE中运行.您可能需要添加一些IE hack,以使其在IE中看起来一样,但是只要您对CSS有一定的了解,就不会太繁琐.
"since i m creating this table through c sharp code i can''t do any formatting to this table."

Errm, yes you can. What I would suggest is that you create a stylesheet (contains CSS) that you use to format the display. The way that I would approach this is to generate your popup window once, and then save it out to disk.

Once you have the saved version, create a stylesheet and link it to the saved version. Now, here''s the "clever" bit; open it in Firefox as well as IE, and start to add the styling to your CSS. Periodically do a full refresh of the pages opened in both browsers, and check to see that what you have added looks the same in both.

The reason for doing it in Firefox is that it is much more standards compliant than IE, so you make sure that you get it working in IE first. You may need to add some IE hacks to get it to look the same in IE, but as long as you have a fair knowledge of CSS this is not too onerous.


这篇关于通过C Sharp代码创建HTML表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆