Asp.Net: Javascript Modal Window - c#

I would like to create a javascript modal pop up window to get some values from a user in a ASP.Net 2.0 webpage.
The basic idea is this. When a user clicks a button, a modal window will come up and ask 3 or 4 questions. The asp.net page will not be able to be changed while this window is up. Once the questions have been answered I need to grab the values from this window so the asp.net page has access to them and can handle them in the code behind.
Can I please get some examples on how you would implement this scenario.

Have you looked at the ModalPopupExtender?
http://www.asp.net/ajax/ajaxcontroltoolkit/samples/modalpopup/modalpopup.aspx

The easiest methods would be to either use ModalPopupExtender as mentioned by Jon or potentially use jQuery's thickbox or something similar as well.
Otherwise, you could roll your own JS to do it.

You could use the javascript function 'window.showModalDialog', but it only works in Internet Explorer.
You can pass in and return any number of variables by wrapping them up into an object.

Related

How to fill a web form and submit it with CefSharp

I'm trying to use CefSharp, seems to work fine for now.
I want to fill a form(which is a login form) and submit the form, any idea how I can do this?
I've found there is an ExecuteScriptAsync, but this use JavaScript(I guess a script that should be existing on the page, right?)
Thank you!
You have to use JavaScript. Please Take a look on Documentation https://github.com/cefsharp/CefSharp/wiki/Frequently-asked-questions#CallJS
Another Good Example Trying to simulate user inputs in CefSharp3 (OffScreen) using JavaScript

How can I open a webpage first and then fill in text boxes and click a button and visibly view the results?

[edit] It is a requirement that the webpage spawn and open in IE and allow user manual interaction after the programmatic actions have completed.[/edit]
I've seen a lot of code examples online about opening webpages or filling in webpage textboxes and getting a return value without ever opening them visibly.
I would like to open a webpage in IE, fill in a few textbox buttons
and then click the submit button and view the results visibly.
I am able to do this with a dll called Selenium, but I do not want to use a 3rd party application and it seems that WebBrowser() should be able to do this?
I can post my failed code examples if that would help.
Thanks.
Maybe this qould fit better as a comment, but I don't have enoigh reputation.
Do you know how HTTP-Forms work?
It would probably be easier to send a HTTP-Request to the target of the form you want to fill, including the parameters you would like to fill into the form.
So you don't need any WebBrowser or similar, just a simple HttpWebRequest object, where you specity the target, the method (very likely POST) and the data you'd like to send.
You can use the webbrowser control in Winforms. It is possible to access every DOM object of the website using the control. No need to open the IE externally.
You just need to specify the webbrowser URL as your link.
Then, fill the textboxes with code,
BrowserID.Document.GetElementById("TextboxID").SetAttribute("Value", "NewVaue")
Also, you can click on the button using InvokeMember("click").
There are lots of stuff using WebBrowser. You can learn it here.

Using popup windows in Visual Studio C# and ASP.NET - quick learning

Whenever the "Reserve" button is clicked in my web application (ASP.NET with C#, Visual Studio), a small window should pop up containing detailed options to choose from (drop down lists with values, comboboxes, etc), with a "Next" link, and "Finish", in the end. Changing the values in these controls should update tables I have in the database (Microsoft Sql Server).
Could you point me towards a detailed and useful resource/example of this? I am already using a book for inspiration (Cristian Darie) written in the form of steps / explanations, but scenarios as just described are not included. What should I be looking for? "Using Pop up windows with Visual Studio"? Is what I described known as a popup window?
I don't know JavaScript, is that needed here? Been practising lately a lot with classes, methods, stored procedures, masters, user control type files, handling db tables through Visual Studio classes and methods, etc but still new to these (a month old basically). Thanks a lot!
it's not necessary to use JavaScript, but if you want anything a bit more fancy than just a regular popup window, javascript will be a good friend to you. As I see it it's basically four main ways of doing it:
1
Create a new ASPX file with the "details", send a querystring to the url of the details view in order to connect the popup with the data from the main window. a key to this is the "target" property of the html "a" tag. For example:
Details
2
Create a popup window with some custom properties (i.e toolbars window size of popup etc) using regular javascript. Look for window.open in javascript.
Example:
Details
3
Using jQuery to open the popup in a modal dialog fashion using a lightbox. For this alternative I don't have any example, but google jQuery lightbox, there are heaps of them. Use that with an AJAX-call and achieve your goals.
4
And at last, use ASP.NET AJAX Control Toolkit (look here:
http://www.asp.net/ajaxlibrary/act.ashx) Download and install, use the ModalPopupExtender (tutorial here: http://www.asp.net/ajaxlibrary/act_ModalPopup.ashx) from the toolkit, in which case you design your "details" view in a <asp:Panel> control and then using CSS and the ModalPopupExtender to display and hide the details, the looks will be like the lightbox but you don't have to create a separate ASPX page for this option, but you can use the same ASPX.
I've worked alot with all four options, and i tend to like the 4th alternative the best, but we all have our own taste.
Good luck, and feel free to ask away for more detailed information. :)
let's take this step by step. In order to send that information, I think the
easiest way would be to store the parameters as session variables and then reload them
when the popup is closed, you can reload the parent window using the "onunload" event in
Javascript, for example
<body onunload="window.opener.location.reload(true);">
This would in
itself reload the parent window whenever the user closes the popup. IF you want it to close
when the user saves changes (and your session variables are set), use this code in order to reload
the parent window and close the popup. Put this code in the code behind, just before the
end of your method that saves the data:
Page.ClientScript.RegisterStartUpScript(this.GetType(),"close","<script language=javascript>window.opener.location.reload(true);self.close();</script>");
To learn javascript, have a look at codeproject.com, they have a lot of articles regarding
javascript (among other things), often with example code. :)
I made a quick example here: http://www.4shared.com/zip/LPtR1gbx/pop.html
I would recomment using a <div> element rather than an actual new browser window.
It eliminates the need to pass the contextual information from the pop-up window back to the original window along with all the complexities involved with it (including things like the user inadvertently clicking off the pop-up window, clicking multiple times and thus bringing up multiple copies of the pop-up window, and so forth).
By using a <div> that "pops up", via controlled visibility through CSS or JavaScript, the entire context is kept to the same web page, making life so much easier overall.

Display data in a popup window in ASP.NET using jQuery?

I am making an ASP.NET application. I have a page which displays a list of data [as a GridView].
I need to display a list of objects [as a GridView] in a new view over the current view, not a new window but a kind of AJAX popup, so that the context shiftes on the page to the new view/form!!
Shall i use Modal Window for this? If so, how shall I do it, as the function to open the modal shall be fired when an item of the GridView is selected?
Is there any plugin which can simplify my task?
You could always try the ASP.net Ajax Control Toolkit
http://www.asp.net/ajax/ajaxcontroltoolkit/samples/modalpopup/modalpopup.aspx
It supported by the ASP.net team and it's really easy to use!
There is a good plugin called blockUI for jQuery that will let you achieve this quite easily.
You can use it to show any HTML that you desire or even load an iFrame using that. You can download this plugin and find examples here
http://jquery.malsup.com/block/
If you post some sample code I can probably help you create your modal pop up!
Please do vote up my answer or mark the checkbox next to it, if I helped you at all. Thanks :)

Messagebox for Web Forms

How do I create a Messagebox in ASP.NET web forms?
I can't add system.windows.form.
Please help. I don't want to do it in javascript.
To pop-up a message box you use alert() in JavaScript. You have to use JavaScript to do this.
You can use a ModalPopup from the ASP.NET AJAX control toolkit.
Of course, behind the scenes, it uses JavaScript, but you don't have to write the JavaScript yourself.
in web you have 2 chooices:
create a div and show / hide it with the message
use the alert or confirmation box with javascript
if you're using ASP.NET, and you want this kinda of things out-of-the-box I strongly suggest you to download and use the ASP.NET Toolkit
you will see many solutions in the left side that you can use in your project and one of them is the Modal Popup ... check them out!

Categories

Resources