条件Javascript函数 [英] Conditional Javascript function

查看:65
本文介绍了条件Javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我对javascript相当陌生,我必须根据服务器端的某个函数(服务器级代码)返回(true或false)运行javascript函数,但我无法这样做.

例如该方法将检查数据库中是否不存在从网格中选择的项目,然后用户应获得提示该项目不存在.是否要继续?".

现在,仅当以上条件(即数据库中的项目不存在)为真时才弹出此消息框,否则为非.

请帮帮我.

谢谢

Varun Sareen

Dear Friends,

I am new to javascript rather very new and i have to run a javascript function on the basis of what a function (server level code) at server side returns (true or false) but i am not able to do so.

for e.g. the method is checking that whether the selected item from the grid doesn''t exists in the database then the user should get a prompt that "this item doesn''t exists.Do you want to continue?".

Now this message box should only get popup when the above condition i.e., item doesn''t exists in database is true else not.

Please help me.

Thanks

Varun Sareen

推荐答案

尝试使用 Page.RegisterStartupScript方法 [ ^ ]

使用它们,您可以根据特定条件(特定于页面)从服务器端将脚本注入到页面中.

有关如何使用它的示例:如何使用RegisterClientScriptBlock& RegisterStartupScript [^ ]
示例2 [
Try using Page.RegisterClientScriptBlock Method [^] OR Page.RegisterStartupScript Method[^]

Using them, you can inject the scripts into a page from server side and based on certain condition (and specific to page.)

For samples on how to use it: How to Use RegisterClientScriptBlock & RegisterStartupScript[^]
Sample 2[^]


<pre><br />
<br />
<script type="text/javascript"><br />
function checkThis(x)<br />
{<br />
    if( x == number)<br />
    {<br />
        return true;<br />
    }<br />
    else<br />
        return false;<br />
}<br />
<br />
<br />
</script></pre>


然后您可以从身体或任何地方调用它.


and after that you can call it from the body or where ever you want.


这篇关于条件Javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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