请教一个window.onload的问题
jcins 2008-07-07 12:19:10 A.aspx:
<script language="javascript" type="text/javascript">
function Select_img(imgid,str){
if (document.getElementById(str).value!=""){
document.getElementById(imgid).innerHTML="<img src='/upload"+document.getElementById(str).value+"' width='280' height='160' >";
}
else{document.getElementById(imgid).innerHTML="";}
}
function Select_img_load(){
//Select_img('pic_sfza','<%=add_pic_shenfenzhenga.ClientID %>');
//Select_img('pic_sfzb','<%=add_pic_shenfenzhengb.ClientID %>');
}
</script>
身份证图片:<br /><span id="pic_sfza" /><br /><br /><span id="pic_sfzb" />
<asp:TextBox ID="add_pic_shenfenzhenga" runat="server" Width="120px"></asp:TextBox>
<asp:TextBox ID="add_pic_shenfenzhengb" runat="server" Width="120px"></asp:TextBox>
<%
add_pic_shenfenzhenga.Attributes["onpropertychange"] = "Select_img('pic_sfza','" + add_pic_shenfenzhenga.ClientID + "')";
add_pic_shenfenzhengb.Attributes["onpropertychange"] = "Select_img('pic_sfzb','" + add_pic_shenfenzhengb.ClientID + "')";
%>
--------------------------
A.aspx.cs:
protected void Table_kehu_RowEditing(object sender, GridViewEditEventArgs e)
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "", "window.onload=function(){Select_img('pic_sfza','" + add_pic_shenfenzhenga.ClientID + "');Select_img('pic_sfzb','" + add_pic_shenfenzhengb.ClientID + "');}", true);
}
---------------------------
麻烦大家看一下.页面打开的时候想实现自动执行Select_img('pic_sfza','" + add_pic_shenfenzhenga.ClientID + "');Select_img('pic_sfzb','" + add_pic_shenfenzhengb.ClientID + "');这两句,但这样执行之后只执行了第一句,第二句总是提示错误,document.getElementById为空或不是对象.不知道什么原因.麻烦大家帮帮忙!!