4月17日
7.表格点击改变颜色
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
12.Panel 横向滚动,纵向自动扩展
<asp:panel style="overflow-x:scroll;overflow-y:auto;"></asp:panel>
13.回车转换成Tab
<script language
=
"
javascript
"
for
=
"
document
"
event
=
"
onkeydown
">
if
(event.keyCode
==
13
&&
event.srcElement.type
!=
’button’
&&
event.srcElement.type
!=
’submit’
&&
event.srcElement.type
!=
’reset’
&&
event.srcElement.type
!=
’’
&&
event.srcElement.type
!=’textarea’);
event.keyCode
=
9;
<
/script>
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
onkeydown
=
"
if(event.keyCode==13) event.keyCode=9
"
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
14.DataGrid超级连接列
DataNavigateUrlField="字段名" DataNavigateUrlFormatString="http://xx/inc/delete.aspx?ID={0}"
15.DataGrid行随鼠标变色
private
void
DGzf_ItemDataBound(
object
sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
if (e.Item.ItemType!=ListItemType.Header)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
e.Item.Attributes.Add( "onmouseout","this.style.backgroundColor=\""+e.Item.Style["BACKGROUND-COLOR"]+"\"");
e.Item.Attributes.Add( "onmouseover","this.style.backgroundColor=\""+ "#EFF3F7"+"\"");
}
}
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
24.在DataGrid中有3个模板列包含Textbox分别为 DG_ShuLiang (数量) DG_DanJian(单价) DG_JinE(金额)分别在5.6.7列,要求在录入数量及单价的时候自动算出金额即:数量*单价=金额还要求录入时限制为 数值型.我如何用客户端脚本实现这个功能?
<asp:TemplateColumn HeaderText="数量">
<ItemTemplate>
<asp:TextBox id="ShuLiang" runat=’server’ Text=’<%# DataBinder.Eval(Container.DataItem,"DG_ShuLiang")%>’
οnkeyup="javascript:DoCal()"
/>
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
<asp:RegularExpressionValidator id="revS" runat="server" ControlToValidate="ShuLiang" ErrorMessage="must be integer" ValidationExpression="^\d+$" />
</ItemTemplate>
</asp:TemplateColumn>
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
<asp:TemplateColumn HeaderText="单价">
<ItemTemplate>
<asp:TextBox id="DanJian" runat=’server’ Text=’<%# DataBinder.Eval(Container.DataItem,"DG_DanJian")%>’
οnkeyup="javascript:DoCal()"
/>
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
<asp:RegularExpressionValidator id="revS2" runat="server" ControlToValidate="DanJian" ErrorMessage="must be numeric" ValidationExpression="^\d+(\.\d*)?$" />
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
</ItemTemplate>
</asp:TemplateColumn>
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
<asp:TemplateColumn HeaderText="金额">
<ItemTemplate>
<asp:TextBox id="JinE" runat=’server’ Text=’<%# DataBinder.Eval(Container.DataItem,"DG_JinE")%>’ />
</ItemTemplate>
</asp:TemplateColumn><script language="javascript">
function DoCal()
{
var e = event.srcElement;
var row = e.parentNode.parentNode;
var txts = row.all.tags("INPUT");
if (!txts.length || txts.length < 3)
return;
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
var q = txts[txts.length-3].value;
var p = txts[txts.length-2].value;
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
if (isNaN(q) || isNaN(p))
return;
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
q = parseInt(q);
p = parseFloat(p);
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
txts[txts.length-1].value = (q * p).toFixed(2);
}
</script>
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
32.变量.ToString()
字符型转换 转为字符串
12345
.ToString(
"
n
"
);
//
生成 12,345.00
12345
.ToString(
"
C
"
);
//
生成 ¥12,345.00
12345
.ToString(
"
e
"
);
//
生成 1.234500e+004
12345
.ToString(
"
f4
"
);
//
生成 12345.0000
12345
.ToString(
"
x
"
);
//
生成 3039 (16进制)
12345
.ToString(
"
p
"
);
//
生成 1,234,500.00%
字符型转换 转为字符串
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
获得字符串实际长度(包括中文字符)
//
获得字符串oString的实际长度
public
int
StringLength(
string
oString)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
byte[] strArray=System.Text .Encoding.Default .GetBytes (oString);
int res=strArray.Length ;
return res;
}
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
//获得字符串oString的实际长度
public int StringLength(string oString)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
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)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
webcontrol.Attributes .Add ("onkeydown", "if(event.keyCode==13) event.keyCode=9");
}
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)