Click here to Skip to main content
15,921,660 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've used java only in the past and I'm still getting used to C# so I need to know if it's possible to ask for and accept user input by means of a JoptionPane equivalent.
Bear in mind, I'm working with a WebForm and not a normal Form

I've used ScriptManager.RegisterStartupScript before to display a message but this time I need to also accept input.

All help is appreciated.
Posted
Comments
ZurdoDev 3-Sep-15 13:34pm    
A dialog? I'd suggest learning jQuery and then use Jquery UI dialog.
Member 11956930 3-Sep-15 13:41pm    
Is there no built in method?
If there isn't I could always call up a WebForm and get it to do it but I'd much rather use a built in method.
ZurdoDev 3-Sep-15 13:50pm    
Built in dialog? The input() javascript function but I don't think anyone uses it because it's ugly.
Member 11956930 3-Sep-15 13:52pm    
Is there any documentation I could use to try that out?
ZurdoDev 3-Sep-15 13:54pm    
Sorry, it's actually prompt(). http://www.w3schools.com/jsref/met_win_prompt.asp

1 solution

It can be nearly anything. First of all, it's not a good idea to directly transfer the UI ideas from Swing to WebForms, where the basics of technology are very different. By this reason, there is no exact "input equivalent", and cannot be. What to do practically, depends on what exactly you want to achieve. Similarity to JOptionPane cannot be a real goal. The real goal should be formulated in semantically sensitive form.

First of all JOptionPane is used to pop-up some dialog. It's a bad idea to pop-up a web page. Such action is intrusive, inconvenient for the users, and will be blocked by many through some browser plug-in. At the same time, if you really need some modal behavior, you can mimic it on the same page, which should work perfectly fine. One way to do it is the jQuery UI dialog plug-in: https://jqueryui.com/dialog[^].

Also, you can find many 3rd-party jQuery plugin collectively known as "modal popup", featuring different visual effects and styles, such as transitions, and, notably, dimming of the rest of the page. Please see:
http://bfy.tw/AJH[^].

If you need to learn jQuery (highly recommended), please see:
http://en.wikipedia.org/wiki/JQuery,
http://jquery.com,
http://learn.jquery.com,
http://learn.jquery.com/using-jquery-core,
http://learn.jquery.com/about-jquery/how-jquery-works (start from here).

But, more importantly, re-thing the whole idea. Do you really need to input data in a modal manner, to give a modal request to a user? How about a way more powerful model where the user can edit some changes in data at any moment of time? It may need more work, but can provide a lot more usability. The area for entering the parameters can be something line a "div", or some extender control (http://bfy.tw/1ccA[^]).

As I say, it can be nearly anything.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900