服务器端验证消息 [英] server side validation message

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

问题描述

我使用..

 <   pre     lang   = < span class =code-keyword> sql >  response.write(<   script  > 提醒(' < span class =code-string> error')<   /   script  > ); 
返回;





显示消息,但在显示消息时它不显示任何页面内容但我想知道的是有没有办法显示这个脚本消息,可以显示页面内容和massege但不会在错误原因时将数据回发到服务器< / pre>



 <   pre     lang   =  sql >  this.Page.ClientScript.RegisterStartupScript(); 
返回;





正在运行,但在此代码之后它不显示控件,直到我们在消息框上单击确定___________



for exapmle我想要在codeproject上显示的相同效果发布评论后发生错误它说我们的服务器发布评论或类似的东西时工作过度问题和它在点击提交之前显示消息框页面上的所有内容

解决方案

如果您要使用

 Response.Write 

从您的代码中,行为将与您上面描述的相同。背景将为空白,直到您在警告框中单击确定后才会呈现。通常我在这些场景中做的是保留一个asp Label&页面上固定位置的asp图像控件,其文本设置为空白。优点是我使用相同的标签作为信息,警告和&错误。例如,如果发生错误,我将显示图像的错误图标,并且消息将显示在标签中。同样,对于信息和警告您可以使用不同的图标来通知用户。因为它只是一个asp标签,它不会停止渲染你的页面。



或者,你也可以使用ajax,如果你想坚持浏览器的信息窗口。我个人,更喜欢前一种方法。


如果我在RegisterStartupScript()中使用window.onload alert(),但是如何异步生成信息框的浏览器窗口,否则我的问题是解决

I use ..

<pre lang="sql">response.write(<script>Alert('error')</script>);
return;



to show the message but while showing message it doesnot show any of page content but i want to know is there any way to show this script message which can show page content and massege but not postback the data to server when error cause</pre>

<pre lang="sql">this.Page.ClientScript.RegisterStartupScript();
return;



is working but it doesnot shows the controls after this code untill we click ok on message box___________

for exapmle i want the same effect as it shows on codeproject after something goes wrong on posting comment it says "our server is overworked problem on posting comment or something like that" and it shows message box everything on page that was before clicking submit

解决方案

If you would use

Response.Write

from your code then, the behaviour would be same just as you described above. The background will be blank and will not be rendered until you click OK on the alert box. Usually what I do in these scenarios is that I keep a asp Label & a asp image control at a fixed location on the page whose text is set to blank. The advantage is that I use the same label for information, warning, & error. For ex, if an error occurs, I will display the error icon for the image and the message will be displayed in the label. Similarly, for information & warning you can use different icons to notify the user. And since it's just a asp Label, it will not stop the rendering of your page.

Alternatively, you can also use ajax, if you want to persist to the browser's window for information. I personally, prefer the former approach.


its working ok if i use window.onload alert() in RegisterStartupScript() but how to generate browser's window for information box in asynchronously otherwise my problem is solved


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

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