views:

327

answers:

2

The JavaScript prompt command

prompt("sometext","defaultvalue");

is a useful way to easily prompt the user to provide a value. But it can't really be a part of any polished web 2.0 application (The dialog looks horrible).

Is there any existing component to display a modal dialog that will prompt a user for a value? I can use a pure JavaScript solution or anything developed for ASP.NET

A: 

You can code your own solution with a div containing an input field and a button and some javascript to show/hide the div.

This will not block the javascript code flow so you will have to set a callback function on the Close/Ok button.

If you are ok with JS libraries almost all of them have a Dialog widget.

Tahir Akhtar
That is exactly what I'm trying to avoid :)
Ron Harlev
I doubt that there is a way to write blocking code in JavaScript, so pure JavaScript solution is unlikely to be out there. Callbacks/EventHandlers seems to be the only choice.
Tahir Akhtar
By the way I found a language that compiles down to JavaScript and let you code async calls as you were doing things synchronouslyhttp://ajaxian.com/archives/narrative-javascript-async-blocking-for-js
Tahir Akhtar
+1  A: 

I'm sure there are a lot of things that fit the bill in of the most javascript frameworks out there. For instance, there are a few out there for jQuery e.g. Impromptu or if you want something specifically for ASP.NET then there are few things you could probably use from the ASP.NET Ajax Control Toolkit such as the Modal Dialog or of course, you could roll your own!

KnackeredCoder
Impromptu looks like what I need. Going to try it
Ron Harlev
Impromptu worked out very nicely for me
Ron Harlev