Alerting the user from code behind

P

Peter Aitken

I need to alert the user when code behind in a user control encounters
certain data conditions. I'd like to do this with a MsgBox but I know that
code behind cannot call this function, at least not directly. Is there a way
to do this?
 
P

Peter Aitken

Peter Aitken said:
I need to alert the user when code behind in a user control encounters
certain data conditions. I'd like to do this with a MsgBox but I know that
code behind cannot call this function, at least not directly. Is there a way
to do this?

--

To answer my own question

Response.write("<script>alert("The message")</script">)
 
P

Peter Aitken

Adam Kinney said:
I would suggest using a Register method of the Page Class instead. You gain
more control of where the javascript is added to the page and you ensure the
javascript is only added once.

RegisterStartupScript -
http://msdn.microsoft.com/library/d...mWebUIPageClassRegisterStartupScriptTopic.asp

RegisterClientScriptBlock -
http://msdn.microsoft.com/library/d...RegisterClientScriptBlockTopic.asp?frame=true


Adam Kinney
http://www.adamkinney.com


Thanks, Adam. When would you use the Client version versus the Startup
version?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top