如何在C#(Web)中显示消息框或警告框 [英] How to Show message Box or Alert Box In C# (Web)

查看:131
本文介绍了如何在C#(Web)中显示消息框或警告框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



我是新手编程,





我需要一些帮助;





如何添加消息框或向用户显示警报。



例如:





如果textBox为空,警告信息应该来或某些消息框应该来。请填写文本框。





请帮助我同样的.. 。

Dear All,

I am new To programming,


I need some help for;


How to add message Box or Showing an Alert To the user.

example:


if the textBox is blank, the Alert message Should come or Some Message Box should come.i.e Please Fill the TextBox.


Please Help me For the Same...

推荐答案

通过简单的Javascript验证警报消息



alert message validation through Simple Javascript

function validation()
{
if(TextName.text=="")
{
   alert(" please enter Name");
   return false;
}
return true;
}





谢谢



Thanks


大部分时间,对于控件的此类验证,你应该使用验证器。



有六种类型的验证器可用于各种用途,从简单的必填字段到复杂的自定义验证。



请查看以下链接。



http://msdn.microsoft.com/en-us/library/debza5t0(v = vs.100).aspx [ ^ ]



www.w3schools.com/aspnet/aspnet_refvalidationcontrols.asp [< a href =http://www.w3schools.com/aspnet/aspnet_refvalidationcontrols.asptarget =_ blanktitle =新窗口> ^ ]



如果你有疑问,那么你总是欢迎她e询问具体问题。



谢谢

Milind
Most of the time, for such validations of controls, you should be using validators.

There are six types of validators to serve various purposes ranging from simple required field to complex custom validations.

Please check at links below.

http://msdn.microsoft.com/en-us/library/debza5t0(v=vs.100).aspx[^]

www.w3schools.com/aspnet/aspnet_refvalidationcontrols.asp[^]

After that if you have questions, you are always welcome here to ask specific questions.

Thanks
Milind


试试这个。

Try this.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script type="text/javascript">
        function fnValidate() {
            if (document.getElementById("TextBox1").value == '') {
                alert('Textbox can not be empty.')
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:textbox id="TextBox1" runat="server" xmlns:asp="#unknown"></asp:textbox>
        <asp:button id="Button1" runat="server" text="Button" onclientclick="fnValidate()" xmlns:asp="#unknown" />
    </div>
    </form>
</body>
</html></html>


这篇关于如何在C#(Web)中显示消息框或警告框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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