使用JavaScript函数从code被称为特定条件下的背后 [英] using javascript function to be called from code behind under specific condition

查看:89
本文介绍了使用JavaScript函数从code被称为特定条件下的背后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<asp:Button ID="btn_create" runat="server" 
        Text="Create Weekly Report" 
        OnClick="btn_create_Click" />

这是一个用户按钮,code的背后,是

This is a user button and code behind is

con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (!(dr.HasRows))
{
    Page.ClientScript.RegisterStartupScript(
        this.GetType(),
        "alert", 
        "openWinContentTemplate();", 
        true);
}
else
{
    Response.Redirect("entry.aspx");
}
con.Close();

我要调用JavaScript functionif第一个条件是真实的。
但它不工作。结果
我的JavaScript函数

I want to call the javascript functionif the first condition is true. but it is not working.
My javascript function is

function openWinContentTemplate() {
    $find("RadWindow_ContentTemplate").show();
}

这将打开一个radwindow如果条件满足。结果
它不工作会有人plz帮助我。

This opens a radwindow if the condition is satisfied.
Its not working could anyone plz help me out.

推荐答案

我会建议使用AJAX调用的方法,使该方法返回有意义的事。如果你想要做的是显示元素,使该方法返回一个布尔值。

I would suggest using AJAX to call the method and make the method return something meaningful. If all you want to do is show an element, make the method return a boolean.

这篇关于使用JavaScript函数从code被称为特定条件下的背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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