I do have an application containing JavaFX webview. Within the application I am generating a html page and it gets displayed.
Now, if the user clicks or selects text I would like to get the corresponding HTML code of the selection.
Is that even possible?
Thank you!
Sure, you need to handle selection and click events in your web page with JavaScript, i.e. with jQuery and in your event handler function to call you Java method handler. Here is an example of JS-to-Java call - Communicating between JavaScript and JavaFX with WebEngine. This will basically provide a Java object inside a WebView:
JSObject jsobj = (JSObject) webEngine.executeScript("window");
jsobj.setMember("javaBridge", new Bridge());
And this is how it can be accessed from a WebView:
here
Related
(Note: Just to clarify the problem is not specifically related to C1WebDateEdit. It could be with any custom control which require JavaScript to render actual control)
I have many C1WebDateEdit controls in my page. On a button click based on some condition I am displaying JavaScript alert message ScriptManager.RegisterStartupScript. These controls are inside UpdatePanel. The issue I am facing with it is, when these C1WebDateEdit has not value and page displays alert message, it displays "01/01/0001" behind the alert box and on closing alert it shows empty textboxes.
The reason is, C1WebDateEdit creates actual control using JavaScript. and page renders alert message JavaScript before C1WebDateEdit controls' JavaScript.
For example:
HTML markup
alert JavaScript
C1WebDateEdit JavaScript
Logical solution is get alert JavaScript after C1WebDateEdit JavaScript because it will allow C1WebDateEdit to load fully before alert box.
I found no inbuilt way in asp.net to change sequence, so I tries solution given here but It didn't work for me.
One possible solution I am thinking that I create Custom or WebUserControl and place at it last at the page in the UpdatePanel and PreRender event I call ScriptManager.RegisterStartupScript to register alert message. Logically I think it will work but trying to find that any one implemented any other solution for it?.
Other possible solution is use "pageLoaded" event of PageRequestManager. I created below function for temporary fix:
function delayedAlertBox(strMsg)
{
var fnc = function (a, b)
{
//remove reference so on next call it do not show previous alerts.
Sys.WebForms.PageRequestManager.getInstance().remove_pageLoaded(fnc);
alert(strMsg);
}
//add function reference to call on Ajax pageloaded event
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(fnc);
}
and calling in asp.net like simple function as given below:
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "dd", "delayedAlertBox('Hi, how are you?')", True)
But still looking for any other good alternative. If I found other, I will post it.
I have a C# web app that pulls a json object from a web service after a button click even. This object has HTML code saved in one of its properties. I need to popup a window to the user from this server side event that displays this HTML.
The event could also return a list of objects so I would need the ability to display the popups one after the other.
What is the best way this handle this issue?
I found the answer I was lookinf for here
http://www.htmlgoodies.com/beyond/javascript/javascript-dynamic-document-creation-in-new-windows.html
I am new to the ASP.NET MVC 3.0, trying to popup partial view using Jscript/AJAX. Any help is appreciated.
Thanks,
Srini
You can launch a popup window with either javascript or jquery. The popup then points to controller/view so that view is displayed in the popup. If you google opening a popup you'll find lots of resource. Its a client side action so really does not have much to do with mvc. You'll just show your view inthe popup.
You can see this article on how to attach code to launch a popup. This is for webforms but the javascript is still applicable for mvc
Also this SO post
Let's say you create a controller action that returns your partial view, something like this:
public ActionResul get_partial_view()
{
....some logic
return PartialView("partial_view_name");
}
Then in your view where you would like the popup to appear you could use some jquery to load the dom element that will contain the content of the popup window like so:
$.get('/controller_name/get_partial_view', function(html) {
$('#popup-content').html = html;
});
I know my issue is very common and similar types has been asked many times over here, but my problem is somewhat different. I am working on ASP.Net 4.0 web application where on my required page i have ajax toolkit 4 calendar control, toolkitscript manager and few asp controls. Now from that pop up i am doing a save operation on button click. What i want is to close popup window after successful save. Problem is not in saving but after saving , automatically closing the popup screen. I have tried the following ways:
RegisterStartUpScriptBlock(this.GetType,"closeForm","return window.close();") and all other required params
ClientScript.RegisterStartUpScript()--- alongwith params and with both return window.close(); and window.close() also with self.close();
Also i have under the title tag...
I think i have tried all the ways , i can. I feel i am lost. Please help me out....
if your using a script manager on the page...
first create a function to close the calendar in js in your html...
function closeCalendar(){
....
}
then on the codebehind use this to call that js function
string script = string.Format(#"closeCalendar()");
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), UniqueID, script, true);
If the popup you mean is the AJAX Toolkit Modal Popup, you can just call popup.Hide(); in codebehind.
If it is a browser window, did you try to remove the return part from your code?
Note that windows.close() will not work unless the popup is opened via window.open();
Also, did you try to just put the script tag inside PlaceHolder control that is hidden (server-side Visible=false) by default and only shown when you need?
I am building a Web Application using asp.net (C#). I come from windows forms development and find myself in a hard spot. Im making an application where the user should edit some simple information about himself, and thus i need to create a new dialog. How do I do that in asp.net? I have a button which event is handled serverside, and when i click lthis button i want to popup a dialog where i can show my custom web control (or any web control, lets make it generic from the start). How do I go about with doing so?
I got some part of the way by looking at the internet, that i need to make a section and set the z-index to 1000, but how do i make it visible (block)? Please help here as i am completely lost...
/H4mm3rHead
If you're not concerned about using a library, try Microsoft ASP.NET AJAX Control Toolkit, they have several controls that can create something you want (the ModalPopup control).
The AJAX Control Toolkit has a ConfirmButton extender which will do exactly what you are looking for.
I used to do the following:
1. my new pop up is just a new aspx page like any other page
2. add a button (or just a link) that fires a client side java script function
3. in the function I use window.open and put params to open my popup page with no toolbars or scrollbars and proper size to its content
check this for more info on #3