服务器端警报问题 [英] Serverside alert problem

查看:82
本文介绍了服务器端警报问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,
我已经在服务器端编写了此代码以进行警报,但出现以下错误.

dear all,
i have write this code for alert in serverside but give me fololwing errors.

Response.Write("<script language='javascript' type='text/javascript'>alert('This EmailID Allready Exist. Please Enter valid EmailID')</script>")


错误消息:-Sys.WebForms.PageRequestManagerParserErrorException:收到消息
从服务器无法解析.导致此错误的常见原因是
通过调用Response.Write()修改响应,响应详细信息:错误
在''< script language =''Ja''附近进行解析.

感谢您的问候,


Error message:-Sys.WebForms.PageRequestManagerParserErrorException: The message received
from the server could not be parsed. Common causes for this error are when the
response is modified by calls to Response.Write(), response Details: Error
parsing near ''<script language=''Ja''.

Thanks n regards,

推荐答案

您不能在asp.net中使用response.write文字值.在过去,人们会使用response.write在经典的ASP中创建HTML.

正确的方法是使用onClientClick,它会在触发诸如回发事件之类的处理程序之前先触发您的Javascript,这样,如果Javascript不喜欢该值,则可以取消回发.

You can''t response.write literal values in asp.net. Back in the old days, folks would use response.write to create HTML in classic ASP.

The proper way to do it is to use onClientClick, which will fire your Javascript first, before firing a handler such as a postback event, that way you can cancel the postback if the Javascript doesn''t like the value.

button.onClientClick = "alert(''This EmailID Already Exist. Please Enter valid EmailID''; return false;)"



这将触发Java脚本中的消息框,但是最佳实践是实际编写一个更复杂的Javascript函数,该函数将验证数据,然后触发消息框,并返回true触发postback事件,或者返回false取消它. br/>
response.write的正确用法之一是响应代码中的HTTP页面请求,然后回复response.write("Error 500").



That will fire the message box in Javascript, but best practice is to actually write a more complex Javascript function, that will validate the data, and then fire the messagebox, and return true to fire the postback event, or false to cancel it.

One of the proper uses for response.write is to respond to a HTTP page request in code, and reply response.write( "Error 500" ).


我相信那里的所有解决方案都对吧
I believe all solution there Right


尝试为
Page.RegisterStartupScript("StatusMessage", "<SCRIPT LANGUAGE='JavaScript'>alert('This EmailID Allready Exist. Please Enter valid EmailID');</Script>");


这篇关于服务器端警报问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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