c#.net中的Javascript警报消息 [英] Javascript alert message in c#.net

查看:69
本文介绍了c#.net中的Javascript警报消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的系统实际应该在用户进入页面或刷新页面时显示警报消息,而无需用户输入任何内容。它将识别sqlcommand并基于它工作。

实际上我尝试创建自己但不工作。有什么建议吗?



这是我的代码:

我的c#代码:

my system is actually should show the alert message without any input from users when the users come into the page or when they refresh it. it will identify the sqlcommand and work based on it.
actually i try to create my own but not working. any suggestion guys?

here is my code:
my c# code:

if (Page.IsPostBack)
{
   SqlConnection connection = new SqlConnection("Data Source=MELINA_YEO-VAIO; Initial Catalog=InventorySystem; Integrated Security=True");
   connection.Open();
   SqlCommand abc = new SqlCommand("Select case when (P_Amount <= SafetyStockamount) then 'Limit stock has been reached' end as Alert from Product");
   Page.RegisterStartupScript("ScriptDescription", "<script type=\"text/javascript\"> alert('Limit stock has been reached');</script>");
}





我的javascript代码:



my javascript code:

<script type="text/javascript">
    alert('Limit stock has been reached!');
</script>

推荐答案

首先从数据库中获取价值。如果你不知道怎么做,请看:如何从Store过程检索输出参数并在vb.net中获取值? [ ^ ]和存储过程输出参数asp.net c# [ ^ ]



根据您的情况检查此值并相应地显示警报。



问候..
First get value out of your DB. If you don't know how to do it see this : How to retrieve output parameter from Store procedure and get value in vb.net?[^] and Stored procedure output parameter asp.net c#[^]

Check this value against your condition and show the alert accordingly.

Regards..


System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page,typeof(Page),Script ,Javascript:alert('msg');,true);
System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "Javascript:alert('msg');", true);


你能不能这个



可能如果我没错了



Can you try this

may be if i am not wrong

string jScript;
jScript = "<script>alert('Limit stock has been reached.')</script>";
this.Page.RegisterStartupScript("keyClientBlock", jScript);


这篇关于c#.net中的Javascript警报消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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