哈,离
总结一下散乱的开发点滴(4) (高手勿入) 已1年半了,现在继续,不过这次比较少了
![](https://www.cnblogs.com/Emoticons/QQ/02.gif)
慢慢补充了,前段日子保存的点滴文件,结果一个木马format C盘时,忘记转移文件了,结果不见了,继续继续
1. Javascript文件(x.js)注意保存为utf8编码喔,不然会出现乱码导致调用方法提示“缺少对象”,当然也可以在引用js文件时,加上编码格式,比如:
<
SCRIPT
language
="JavaScript"
src
="/Js/dragPub.js"
type
="text/JavaScript"
charset
="gb2312"
></
SCRIPT
>
2. Repeater很好用,不过不能设置datakeyfield,放label有点傻,有时item_command事件要用,有没有简单点的实现方法:
例:memberid为主键,作如下设置
[
<
asp:LinkButton
id
="lbApprove"
runat
="server"
CssClass
="cx5"
CommandName
="Approve"
memberid
=<%#DataBinder.Eval(Container.DataItem,"MEMBERID")%
>
>批准加入
</
asp:LinkButton
>
]
后台command事件中的代码如下:
LinkButton lb
=
(LinkButton)e.CommandSource;
String memberID
=
lb.Attributes[
"
memberid
"
].ToString() ;
3. 新打开页面,进行的操作如何影响父页面呢? 用showModelessDiague
父页面
<script language=javascript>
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
function openLogoList()
{
var url = window.showModelessDialog("/GroupLogos.aspx",window,"status:false;dialogWidth:600;dialogHeight:500");
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
function updateLogo(url)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
document.getElementById("imLogo").src = url;
}
</script>
打开的新窗口
<script language="javascript">
function selImg(url)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
var parentArg = window.parent.dialogArguments;
parentArg.updateLogo(url);
window.close();
}
</script>
4. 检查textbox只允许数字英文下划线空格和.
οnblur="value=value.replace(/[^\u4E00-\u9FA50-9a-zA-Z_. ]/g,'')"
5. 已知枚举的数值或类型,获取它对应的枚举类型或值?
(GroupAccessType)Convert.ToInt32(dr["accesstype"])
Convert.ToInt32(GroupAccessType.Public)
就可以咯
6. ASHX处理图片及文件显示的二进制文件如何获取session值?
让它继承IRequiresSessionState,就可以在processRequest事件中,context.Session["xxoo"]来获取啦!
7. Javascript中的select option添加的同时,_option.seleted=true是没有用的,因为此时它还没有添加,所以只能如此设置:
//
给下拉框增加项
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
function
insertOption(obj, _text, _value, _selected)
{
// 如果存在此VALUE,则编辑
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
for (var i=0; i< obj.length; i++)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
if (obj[i].value == _value)
{
obj[i].text = _text;
return;
}
}
// 若不存在此VALUE,新建
var _option = document.createElement("OPTION");
_option.text = _text;
_option.value = _value;
obj.add(_option);
if (_selected)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
obj.selectedIndex = obj.length-1;
}
}