使用ajax时出现警报脚本问题!!!! (C#asp.net) [英] Alert script problem when using ajax!!!! (c# asp.net)

查看:42
本文介绍了使用ajax时出现警报脚本问题!!!! (C#asp.net)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友..
感谢您给予我的答复.

现在我想问一件事,我正在使用服务器端的警报消息框,如您给我的代码一样,如


if(txtusername.text.trim()== string.empty)
{
response.write("alert(``输入用户名'');");
}

在不使用ajax的情况下也可以正常工作,
但是当我使用ajax控件(脚本管理器和更新面板)时,
它不起作用..
Ajax是什么问题?
如果代码中有什么变化,请告诉我..


我也想知道我也可以将警报框用于其他数据格式吗?喜欢验证(日期时间,整数值,电子邮件地址..)

并可以使用IF(condition)来完成它,就像我已经为空文本框做到了吗?

或者,如果您可以告诉我其他服务器端验证方法,请告诉....

非常感谢..::

hi friends..
thanks for your answers given to me..

now i want to ask one more thing that i am using the alert message box in the server side as per your code given to me like


if(txtusername.text.trim()==string.empty)
{
response.write("alert(''Enter username'');");
}

its working fine without using ajax,
but when i use ajax controls (script manager and update panel),
its not working..
what is the problem with ajax??
and if there is something to change in the code, then tell me..


i also want to know can i use alert box for other data formats too?? like to validate (datetime, integer value,email address..)

and can it be done with IF(condition) like i have done it already for the empty textbox??

or if you can tell me other server side validation method then tell....

thanks a lot.. :)

推荐答案

arvinder_aneja写道:
arvinder_aneja wrote:

什么是Ajax问题??
如果代码中有什么变化,请告诉我..

what is the problem with ajax??
and if there is something to change in the code, then tell me..



使用AJAX时,必须使用ScriptManager 来执行脚本.试试这个.



While using AJAX, you have to use ScriptManager for executing the script. Try this.

ScriptManager.RegisterStartupScript(this, 
    this.GetType(), 
    "AlertScript", 
    "alert(''Enter username'');", 
    true);


这篇关于使用ajax时出现警报脚本问题!!!! (C#asp.net)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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