Message window in asp.net web application

how to display a successful save window in asp.net web application using javascript.

any idea ???

+1
source share
4 answers

Instead of registering some kind of JavaScript code, for example:

Response.write("<script>ShowMessage('Successfully saved !');</script>"); 

a little easier to use this built-in method:

 Page.ClientScript.RegisterStartupScript(this.GetType(), "showMyMessage", "ShowMessage('Successfully saved!');", true); 

This is a little cleaner than using Response.Write, and it automatically adds and adds your code with '<script type = "text / javascript">' and '</script>'.

In your ShowMessage (MyMessage) function, you can make a simple warning (), or you can do something like TJ Crowder suggests.

0
source

Option 1

You can place arbitrary content on the page almost anywhere, just by creating and adding absolutely positioned DOM elements, see this question for more information, but mostly

 var element; element = document.createElement('div'); // Or whatever element.style.position = "absolute"; element.style.left = "100px"; element.style.top = "100px"; element.style.width = "200px"; element.style.height = "200px"; document.body.appendChild(element); 

left , top , etc. can be any valid CSS values. You can also use z-index to make sure it is displayed on top of other content.

Of course, when they click on it or something that you want to delete,

 document.removeChild(element); 

If you want to β€œcross out” the base page, etc., you can use the iframe shim to achieve this.

Option 2

Another alternative is to use the JavaScript alert function, but it's pretty intrusive and old-fashioned.

0
source
 alert ( "Successfully saved" ); 

Display a warning dialog box with the specified content and the OK button. See window.alert

The problem with the warning field is that it blocks the user from any further action. It’s better if you can display custom posts in containers like <span> or <div> and place them on the page.

Edit

If you can use jQuery then this has different sets of custom alert boxes.

jQuery impromptu

0
source

Response.write ("<script> alert ('Successfully saved!'); </script>");

or call the javascript function, which takes the Response.write parameter ("<script> ShowMessage ('Successfully saved!'); </script>");

// client side function

ShowMessage function (message) {warning (message); }

0
source

All Articles