2遇到的問題:
如何在表格出現滾動條?
解決方法:
<table>
<tr>
<td class='bodytd' align='center' valign='top' >
<div style='height:178;overflow-y: auto;overflow-x:hidden'>
</div>
</td>";
</tr>
</table>
其中style中可將overflow屬性設置成:auto、hidden、scroll,
須設定div的height,在超過該高度時,auto、scroll將出現滾動條。
3遇到的問題:
制作細線表格
解決方法:
方法1:把表格的cellspacing設置為1,cellpadding和border均為0,分別填充表格的背景色和單元格的背景色。舉例如下:
<table border="0" cellspacing="1" cellpadding="0" bgcolor="#87a4c5 ">
<tr>
<td height=26 width=120 bgcolor=”white”> </td>
</tr>
</table>
則出現淡藍色細框,效果較好
方法2:把cellspacing、cellpadding、border均設置為1,分別設定表格的邊框色和內部單元格的邊框色,注意使內部單元格的邊框色和網頁背景色或表格背景色相同,這樣內部的邊框看上去就和背景融為一體了。舉例如下:
<table width="550" border="1" cellspacing="1" cellpadding="1" bordercolor="#666666">
<tr bordercolor="#ffffff">
<td> </td>
</tr>
<tr bordercolor="#ffffff">
<td> </td>
</tr>
</table>
方法3:用css定義表格的邊框寬度為1個像素。先設置css類table1 { border-top: 0px; border-right: 0px; border-bottom: 0px; border-left:0px},然后在<table>標簽里添加class="table1"。
方法4:做一個和表格等大的圖片作為表格的背景,尤其當你想使表格邊線有倒角時。
關于去除超鏈接的下劃線
解決方法:
可寫作:
在<head>與</head>之間加上
<style>
<!--
a:link {}{text-decoration: none }
a:visited {}{text-decoration: none }
a:active {}{text-decoration: none }
a:hover {}{text-decoration: none }
-->
</style>
這樣的話該格式將應用于該頁面所有的超鏈接
另:可以為該格式類取個名字:
如:
a.mylink:visited { text-decoration: none }
a.mylink:link { color: #3f3f3f; text-decoration: none }
a.mylink:hover { text-decoration: underline }
這樣可以將該格式應用于某個特殊的類,如:
<a href="" class="mylink">…………</>
41.判斷是否為數字 
 /**//// <summary> 
 /// 名稱:isnumberic 
 /// 功能:判斷輸入的是否是數字 
 /// 參數:string otext:源文本 
 /// 返回值: bool true:是 false:否 
 /// </summary> 
  
 public bool isnumberic(string otext) 
 { 
  try 
  { 
   int var1=convert.toint32 (otext); 
   return true; 
  } 
  catch 
  { 
   return false; 
  } 
 } 
獲得字符串實際長度(包括中文字符)
 //獲得字符串ostring的實際長度 
 public int stringlength(string ostring) 
 { 
  byte[] strarray=system.text .encoding.default .getbytes (ostring); 
  int res=strarray.length ; 
  return res; 
 } 
42.將回車轉換為tab 
//當在有keydown事件的控件上敲回車時,變為tab 
 public void tab(system.web .ui.webcontrols .webcontrol webcontrol) 
 { 
  webcontrol.attributes .add ("onkeydown", "if(event.keycode==13) event.keycode=9"); 
 } 
43.datagrid分頁中如果刪除時出現超出索引 
public void jumppage(system.web.ui.webcontrols.datagrid dg) 
 { 
  int int_pageless; //定義頁面跳轉的頁數 
  //如果當前頁是最后一頁 
  if(dg.currentpageindex == dg.pagecount-1) 
  { 
   //如果就只有一頁 
   if(dg.currentpageindex == 0) 
   { 
    //刪除后頁面停在當前頁 
    dg.currentpageindex = dg.pagecount-1;    
   } 
   else 
   { 
    //如果最后一頁只有一條記錄 
    if((dg.items.count % dg.pagesize == 1) || dg.pagesize == 1) 
    { 
     //把最后一頁最后一條記錄刪除后,頁面應跳轉到前一頁 
     int_pageless = 2; 
    } 
    else      //如果最后一頁的記錄數大于1,那么在最后一頁刪除記錄后仍然停在當前頁 
    { 
     int_pageless = 1; 
    } 
    dg.currentpageindex = dg.pagecount - int_pageless; 
   } 
  } 
 } 
textbox的wrap屬性,決定是否自動換行。
3,imagebutton1可以作為圖像地圖使用,
   private void imagebutton1_click(object sender, system.web.ui.imageclickeventargs e)
  {
   int a=e.x;
   int b=e.y;
    //可以得到鼠標點擊的位置,執行不同的操作。
  }
 
  alternatetext屬性,是無法取得圖片時的替代文本。
 
  同樣可以使用  onmouseover="b()" onmouseout="h()"  動態改變外觀。
2。單元格鼠標移動效果
 
<tr id="test" 
onmouseover="javascript:this.bgcolor='#ffddaa'" 
onmouseout="javascript:this.bgcolor='#fffff5'" 
bgcolor="#fffff5">
<td valign="middle" align="center" colspan="2">指定日規則列表</td>
</tr>
隱藏html控件:
<input type=text name=txt1 >
document.xxx.style.display="none";
<script language="javascript">
function tosum1()
{
 document.form1.text1.value="ltp";
 document.form1.text2.style.backgroundcolor="#669999";
}
 
 
function selecttext() { document.form1.textbox6.select(); }
 
 
</script> 
 
失去焦點: onblur="tosum1()"
 
鼠標過來進,出移開效果:onmouseover="b()" onmouseout="h()"  (button也可使用)
 
有關其他事件查看:  htmlinputtextelementevents dispinterface
 
 
設置html控件:
 
 
   this.text1.style["border-top-style"]="none";
   this.text1.attributes["readonly"]="readonly";
   text6.attributes["onclick"]="select()";
 
js 中,一些東西不可用的三種展現方式
我們在web項目中,有時候需要在用戶點擊某個東西的時候,一些東西不可用。如果在客戶端實現。最簡單的就是利用disabled 。下面羅列的其中三種方式: 
依次是:不可用(disabled);用一個空白來代替這個地方(blank);這個區域為空(none)。具體可以查看這個blog的源文件:
dadd 
ccc
  
   
這三種方式其實核心代碼依次是:
obj.disabled = false;
obj.style.visibility = "hidden";
obj.style.display = "none";
我把這三種收集到一起,供以后查找使用方便。
<!--演示代碼開始//-->
<script language=javascript>
function showdisableobject(obj)
{
 if(obj.disabled == false)
 {
  obj.disabled = true;
 }
 else{
  obj.disabled = false;
 }
 var coll = obj.all.tags("input");
 if (coll!=null)
 {
  for (var i=0; i<coll.length; i++)
  { 
   coll[i].disabled = obj.disabled;
  }
 }
}
 
function showblankobject(obj)
{
 if(obj.style.visibility == "hidden")
 {
  obj.style.visibility = "visible";
 }
 else
 {
  obj.style.visibility = "hidden";
 }
}
 
function shownoneobject(obj)
{
 if(obj.style.display == "none")
 {
  obj.style.display = "block";
 }
 else
 {
  obj.style.display = "none";
 }
}
 
</script>
文件下載
有的時候我們不想讓用戶直接在ie中打開已知類型的文件,比如word,而希望能直接下載,這時候可用下面代碼來替換response.redirect
response.contenttype = "application/octet-stream";
response.addheader("content-disposition", "attachment;filename="+httputility.urlencode(yourfilename,response.headerencoding ));
response.binarywrite((byte[])yourfiledata.rows[0]["attachmentcontent"]);
response.end();
用httputility.urlencode可以解決中文文件名亂碼問題。
新聞熱點
疑難解答
圖片精選