在asp.net中调用多个javacripts [英] calling multiple javacripts in asp.net

查看:71
本文介绍了在asp.net中调用多个javacripts的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

在页面加载中添加两个javascript函数后,我在按钮单击上调用了它们
如下:

hi friends,

i''m calling two javascript functions on button click after adding them on pageload
as follows:

btnSave.Attributes.Add("onclick", "return btnClickValidation();btn();"); 


这里btnClickValidation();返回true或false.
因此btn();无法执行
但是,如果我调换呼叫顺序,效果很好..

我想做的另一件事是我要调用btn();.回发发生时 ...这可能吗?如果是的话
在此先感谢


here btnClickValidation(); returns either true or false.
and hence btn(); doesnot executes
however if I swap the calling order it works well..

Other thing that i want to do is I want to call the btn(); when postback happens... Is this possible? If yes Then how
Thanks in advance

推荐答案

//Keep as is simple
function Onclick()  {
    var b = btnClickValidation();
    if (b)
        btn();
    return b;
}

and then

btnSave.Attributes.Add("onclick", "return Onclick();");


只需在btnClickValidation( )函数,因为当我们返回时,它将不会转到您的第二个js函数btn,也可以将其用作.

simply you can call the function btn in btnClickValidation() function because when we return than it will no go to your second js function btn or you can use it as .

btnSave.Attributes.Add("onclick", "var a=btnClickValidation(); if (a == true) {btn();} else { return false;}"); 


这篇关于在asp.net中调用多个javacripts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆