We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Display a message box in ASP.Net  3.5

Cause
Cause asked
on
Medium Priority
2,857 Views
Last Modified: 2012-05-06
Hi,
I know this should be easy enough with javascript but i am failing miserably!
I want to display a choice message box to a user - Yes or No and continue on processing based on the button has clicked. It is not linked to the event of any control.

Can anyone help?

Many THANKS
Comment
Watch Question

Loganathan NatarajanLAMP Developer
CERTIFIED EXPERT

Commented:

Author

Commented:
Thanks loqudotcom. I don't have any event to link the javascript to. I am processing somecode and based on results i get back from the database i want to ask the user a question. if i understand the example correctly that it linked to an event. I just want to call it from vb.net
Faizan SarwarSoftware / Database Developer
CERTIFIED EXPERT

Commented:
Just as discussed by logudotcom but in aspx

<asp:Button  runat="server" ID="test" OnClientClick="return confirm('Are you sure?');" Text="Test" />
Faizan SarwarSoftware / Database Developer
CERTIFIED EXPERT
Commented:
If (your expresion to text)
{
     ClientScript.RegisterStartupScript(this.GetType(), "selectnodealert", @"<script type=""text/javascript"">confirm('please confirm ');</script>");

 
}

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Head of Software Services
Commented:
Hello Cause,

The simple answer is you can't simply stop your code-behind processing, throw a client-side message box and then continue processing just like that. You need to adapt the techniques already described and modify your behind-the-scenes processing to handle the fact that when you need to ask the question you need to end your processing script in the client-side message box, add a handler to this that responds to the option selected and then posts back to your code to continue (if appropriate) or cancel the existing processing.

It is an oft-asked question but there is no way around breaking out of your code and back to the client-side.

Regards,

TimCottee
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.