如何在Asp.net中显示消息而无需使用javascript. [英] How to show Message in Asp.net without help of javascript.

查看:60
本文介绍了如何在Asp.net中显示消息而无需使用javascript.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生/女士,

我在.net上较新(初级软件工程师).我不知道如何在登录"表单中显示消息.如何在单击按钮时显示消息?请帮帮我.

预先感谢,

Shailendra Singh

Dear sir/madam,

I am fresher (junior s/w engineer) in .net. I don''t know how to show a message in Login form. How can I show a message on button click? Please help me.

Thanks in advance,

Shailendra Singh

推荐答案

对于Javascript,您只需要如Sunasara Imdadhusen所说的Alert函数.

对于后面的代码,它有点复杂.只要按钮具有runat="server"属性,并且您已通过OnClick="butLogin_Click"连接了事件处理程序,则此方法应该起作用:
For Javascript, you just need the Alert function as Sunasara Imdadhusen said.

For the code behind, it is a little more complex. As long as the button has a runat="server" attribute, and you have connected up the event handler via OnClick="butLogin_Click" then this should work:
protected void butLogin_Click(object sender, EventArgs e)
    {
    Response.Write("<script>alert('Your Message')</script>"); 
    }


我想你的意思是在网页上显示用户名/密码无效"之类的消息吗?在这种情况下,您正在谈论验证.

尝试使用ASP .NET上的验证控件,或者也可以通过在消息中包含隐藏的Label控件来手动完成工作. :)

我忘了添加.您可以在Button的click事件方法中显示/隐藏Label控件(如果您喜欢此方法).
I suppose you mean showing a message like "User name/Password is invalid" on the webpage? You''re talking about validation in that case.

Try the validation controls available on ASP .NET or you can also do the work manually by having a hidden Label control with your message. :)

I forgot to add. You can show/hide the Label control (If you prefer this method) in the Button''s click event method.


您可以使用标签控件.默认情况下,使其不可见.当您必须显示一些信息时,使其可见,并在标签的text属性中分配要显示的信息.在页面加载中,使标签不可见......否则,您可以使用resnponse.wite方法.
You can take a label control.By default make it invisble..When you have to show some messege make it visible and in the text property of the label assign the messege you want to show..In the page load make the label invisible...............Otherwise you can use the resnponse.wite method.


这篇关于如何在Asp.net中显示消息而无需使用javascript.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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