Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi experts,

I am developing a application in that i restricted size of total records,but i want to generate a windows alert box to notify that limits are exceed


Thanks
Posted
Updated 16-Jan-12 23:10pm
v2

C#
private void MessageBox(string message)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "My title", "alert('" + message + "');", true);
            return;
        }
 
Share this answer
 
You can use
C#
Response.Write("<script>window.alert('Inserted')</script>");

by code or directly script it in Design
 
Share this answer
 
Comments
amolpatil2243 17-Jan-12 5:20am    
but it happening the postback. i dont want postback
The best you can do is to use client-side alert(...) in JavaScript. If this is in response to some sort of data submission then your AJAX response handler needs to do it; if it's in response to client side events then wherever you are trying to add rows, you should do it.

However, model dialogs are annoying and generally web users expect not to see one unless they do something badly wrong. Consider having a non-modal error display within the page, and ideally make it impossible to get the error by doing pre-validation (e.g. disabling the Submit/Add Rows links if they would not be valid).

Bear in mind that some browsers let the user turn off alerts, and by default provide a 'No more alerts from this page' option after a page has created a few. (In Chrome I think you get that on the third one.) After that, anything you send through alert() is simply lost if the user has turned them off. So don't use alert() for critical information, instead use an in-page overlay that blocks further interaction.
 
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