Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 8-Feb-11 23:48pm
v2
Comments
Sunasara Imdadhusen 9-Feb-11 5:56am    
You can use Alert('') to show message!

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:
C#
protected void butLogin_Click(object sender, EventArgs e)
    {
    Response.Write("<script>alert('Your Message')</script>"); 
    }
 
Share this answer
 
Comments
Sunasara Imdadhusen 9-Feb-11 6:15am    
Good call!
Nithin Sundar 9-Feb-11 6:16am    
Good one. A nice way of doing it.
Venkatesh Mookkan 11-Feb-11 0:20am    
Response.Write? Did you forgot ClientScript.IsStartupScriptRegistered?
Suresh Chand Saini 21-Dec-12 0:18am    
how to display msg in lable
OriginalGriff 21-Dec-12 3:08am    
Do not try to hijack threads with unrelated questions - it is rude.
Ask a new question if you have a problem.
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. :)

EDIT: I forgot to add. You can show/hide the Label control (If you prefer this method) in the Button's click event method.
 
Share this answer
 
v2
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900