我在后台page_load中写了
this.b_check.Attributes.Add("onclick","check(file)");
其中b_check是一个asp:button,我想让他执行写在前台的javascript函数check(file)
<script language=javascript type=text/javascript>
function check(file){
var fs = new ActiveXObject("Scripting.FileSystemObject")
var txt=document.getElementsById("txt");
if(fs.FileExists(file))
txt.value="true"; else
txt.value="false";
}
</script>
但是没有执行阿!为什么呢?
this.b_check.Attributes.Add("onclick","check(file)");
其中b_check是一个asp:button,我想让他执行写在前台的javascript函数check(file)
<script language=javascript type=text/javascript>
function check(file){
var fs = new ActiveXObject("Scripting.FileSystemObject")
var txt=document.getElementsById("txt");
if(fs.FileExists(file))
txt.value="true"; else
txt.value="false";
}
</script>
但是没有执行阿!为什么呢?
OnClientClick="check(file)" CausesValidation="False" UseSubmitBehavior="False" Visible="False"
file应该是具体的值吧。
但在cs里,file就要是具体值。
this.b_check.Attributes.Add("onclick","check('"+file+"')");
按楼上说的试试吧,
这个我测试了 但是没有反应 没有得到返回值
看能否调用这个函数