Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popup message 3

Status
Not open for further replies.

Rexxx

MIS
Oct 16, 2001
47
Within my aspx file I need to code it to display a popup message (as opposed to using an html page message) to inform the user whether a certain record was successfully entered into an SQL database. As of now my sql stored procedure to add a record returns a value -1 if the record is unsuccessful that I could use in an if statement. I have used similar code to display a certain popup message upon button clicks such as this message on a delete record button click:

btndelcompany.Attributes.Add("onClick","javascript: return confirm('Are You Sure You Want to Delete this Record?')")

So I'm fairly certain it can be done but not sure how to setup. Can you help?
 
Hi Rexxx,
I think u have just declared DivScript inside the code. and Not included in the design Layout. So U drag and Drop the Flow Layout Panel from the HTML controls Toolbox and name the ID as DivScript and then run the code.. u will not get the error..
 
Here is a VB .Net solution to do away with the need to create an object for the labels (i.e., label1 and label2 script above). I've tested and it works fine.

RegisterClientScriptBlock(&quot;InsertFail&quot;, &quot;<Script>alert(&quot;&quot;Company was not Entered (Federal Tax ID may already exist)&quot;&quot;)<&quot; & &quot;/Script>&quot;)
RegisterClientScriptBlock(&quot;InsertSuccess&quot;, &quot;<Script>alert(&quot;&quot;Company was Successfully Entered&quot;&quot;)<&quot; & &quot;/Script>&quot;)
RegisterClientScriptBlock(&quot;Redirect&quot;, &quot;<Script>location.href=&quot;&quot; & &quot;/Script>&quot;)
 
The caveat to this method is that it only works on a page object. I could not get it to work on a user control, which is why I opt for the former solution.
penny1.gif
penny1.gif
 
Hey Mark,

Just wanted to say thanks again man! That tip was awesome!

Just a note to everybody who may have had issues with the whole double quote things:

YOU DON'T NEED ALL THE QUOTES!
This line worked for me:

lblError.Text = &quot;<Script language=javascript>alert('Save Successful')</Script>&quot;

Its also easier to use it this way if you want to add an error message or something from your code behind, like this:

lblError.Text = &quot;<Script language=javascript>alert('Save Failed:&quot; & err.Message & &quot;')</Script>&quot;

Jack

 
heh, k, just a note on my last post there:

that only works if whatever your code part is has no (') in them. You'd have to parse them out first.
(doh!)

Jack
 
Hey Jack the reason for all the quotes was that Rexxx wasn't using code behind. His code was written intermingled with the page. If it isn't intermingled then ya you don't need all the other stuff.

Personally I like code behind way better and always use it.

Your welcome again and thanks for the star... again.

This is one long ass thread That'l do donkey, that'l do
[bravo] Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top