附5.<colgroup >标签用于对表格中的列进行组合<colgroup > 标签用于对表格中的列进行组合,以便对其进行格式化。
如需对全部列应用样式,<colgroup > 标签很有用,这样就不需要对各个单元和各行重复应用样式了。
<colgroup > 标签只能在 table 元素中使用。
例:
<table width="100%" border="1" >
<colgroup span="2" align="left" ></colgroup >
<colgroup align="right" style="color:#0000FF;" ></colgroup >
<tr >
<th >ISBN</th >
<th >Title</th >
<th >Price</th >
</tr >
<tr >
<td >3476896</td >
<td >My first HTML</td >
<td >$53</td >
</tr >
</table >
附6.JS动态执行函数示例<script type=”text/javascript” >
function Mytest(message)
{
alert(message);
}
Var jsFunction=Mytest”;
if(typeof(jsFunction) == "string")
{
jsFunction = eval(jsFunction);
}
jsFunction (“消息”);
附7.JS调用C#方法示例(1)使用<%=方法或属性% >
Var data = '<%=GetDemandDataString("' + PageIndex.toString() + '") % >';
可以无参数,如果有参数必须是字符类型,缺点是只在编译时取值,取值后不变
(2)利用ScriptManager控件
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" / >
注意一定要设置EnablePageMethods="true",而且所调用的后台方法必须是WebMethod静态方法
function myLazyLoad(grid, e) {
//第一页在页面Page_Load中加载
var PageIndex;
if (e.currentPageIndex <= 1) {
PageIndex = 1;
}
else {
PageIndex = e.currentPageIndex;
}
PageIndex = PageIndex + 1;
PageMethods.GetDemandDataString(PageIndex, e.pageSize,myLazyLoad_OnSucceeded, myLazyLoad_OnFailed);
e.currentPageIndex = PageIndex;
}
//成功时的处理方法
function myLazyLoad_OnSucceeded(result) {
var dom = new ActiveXObject("MSXML.DOMDocument");
dom.loadXML(result);
var grid = document.getElementById("<%=SmartGrid2.ClientID % >");
grid.append(dom.documentElement);
}
//失败时的处理方法
function myLazyLoad_OnFailed(error) {
}
后台代码示例:
//懒加载某页数据
[System.Web.Services.WebMethod]
public static string GetDemandDataString(int pageIndex,int pageSize)
{
XmlDocument doc;
string selectCmdString = "Select TOP(" + pageSize.ToString() + ") * FROM (Select *,"
+ " ROW_NUMBER() OVER (ORDER BY GID) AS ROWNUM FROM Storage_Goods as tab) as tab"
+ " Where tab.ROWNUM > " + ((pageIndex - 1) * pageSize).ToString()
+ " ORDER BY tab.ROWNUM";
DataSet currentDs = new DataSet();
using (SqlConnection currentConn = new SqlConnection(_connectionstring))
{
//获取数据
currentConn.Open();
SqlDataAdapter currentSda = new SqlDataAdapter(selectCmdString, currentConn);
currentSda.Fill(currentDs, "Storage_Goods");
doc = MyConvertDataTableToXML(currentDs.Tables["Storage_Goods"]);
currentConn.Close();
}
return doc.InnerXml;
}