Mouse Rollover event for ASP.NET control - javascript

I have a ASP.NET ImageButton control (no AJAX) with a Image_Click event that fetches data from SQL server. Now I want to add a Mouse Rollover to the Image Button that should fetch the data from the SQL server and display it on a Label.
I know you can add a Javascript Mouse Rollover event on the Image Button.
imgae_Button.Attributes.Add("onmouseover", "myJacascriptFunction()");
How do I get the Javascript code fire Server side code to fetch the SQL data?
Can this be done?
EDIT: Clarification onclick() event not only fetches data from SQL but also writes to another table. This event has alreday been coded without AJAX.
It is the mouse rollover event that I need help with. When the user hovers over the image, data should be fetched from SQL database & displayed on a label control.

This sure can be done, and will almost certainly involve AJAX.
In your mouse rollover event you want to define myJavascriptFunction() to click the image button on the users behalf, this will subsequently postback to the server as if the user had simply clicked.
You then want to place the image button and the label you want to show the answer into an UpdatePanel and ensure you stick a ScriptManager on the page too to handle the request/response.
This should achieve what you want.

Related

How to store array from on-click and use it in dropdown

I have an HTML page that has an option for drag-n-drop and a "Preview" button. I want to call a function on the click event of that button, which will fetch all the files that are dragged onto the page. When I press this button, it opens a <px-modal> (a popup which displays some data), and it has a dropdown (<paper-dropdown> and <paper-item>), which should display the filename fetched earlier.
So I have the data, but I don't know how to store it or display it as dropdown content.
I have tried the <template> tag, but it fires on page-load when I need it to fire after the files are dropped onto the page. Otherwise, the data is null.
How do I solve this?
Without some code to look at, it's hard to help you but in general, my advice will be to use a service to store your data and all your directive/controller that needs to have access to the data should havce a dependency on this service.
Have a look at option 1 on this answer
If that's not what you're looking for, post more details, create a jsFiddle to show us where you are so we can help you better.

How to make pages progress stepwise on a popup?

Can someone please explain how can I go about creating the following page and what techniques should I adopt:
The user should be able to click on a button which should result in a popup.
The popup should have a static page with instructions and button to click which takes the user to the next step in the same popup.
At the next step the functionality should run to take input from the user and save it to the server.
The user should see a confirmation finally and on clicking finish, the popup should hide.
From what I understand, I should try the following:
use javascript onclick and fadeIn function to create the popup.
continue changing the same div using onclick and AJAX to create stepwise kind of a format and carry out the functionality.
use XMLHTTPRequest to upload data acquired and finally use fadeOut to hide the popup.
The reason why I am thinking in these lines is because I have had very little exposure to web designing and hence would love to get some expert views on if this is the right approach and if not then what should be a better way to do it. Is there is some existing literature/method which talks about it?
Any help would be much appreciated.
For first step
Use javascript onclick function. But before this keep your static content ready and than use jQuery UI to appear it as good Dialog Box. For example see this
For second step
The user will never know that you have changed the dialog. Just you can load new dialog with new content in it. When you click button on first page, make that first dialog box is closed.
For third step
Instead of static content make the response set to dialog, here you may use Ajax/post call.
Las step
Its not compulsion to use XMLHTTPRequest. You can even submit form in jQuery post/ajax. Than you can reload the page with confirmation message send in response from server or you may use jQuery to make the confirmation message appear.

Dropdownlist Postback interferes with Javascript

My ASP page has a DropDownList (DDL) and a bunch of checkboxes. When my user selects a DDL item, I have some JS/jQuery code to make several checkboxes invisible according to some logic. However, the postback of the DDL, needed to run the C# code-behind event handler, causes a redraw of the entire page and makes all checkboxes visible.
How can I prevent the postback from wiping out the actions of the JS? Should I store visibility bits in something like ViewState?
Is it possible to have the JS code run AFTER the postback, instead of before?
Is it possible/easy to use CallBack instead of PostBack for the ASP DropDownList? I was thinking that the fun of Ajax was avoiding postbacks and only updating the control instead of the entire page.
Well if the dropdown posts back in the same action that you flip the switch for the checkboxes, why not then put the logic to show/hide checkboxes on the server instead of the client? You can use the hidden field approach, and that would work fine.
The callback means the UI needs updated by JavaScript. I don't know what all the postback updates, but you would have to send everything up via JSON, and refresh the UI via JavaScript. So only you can make that call.

Lotus Notes:Web page refresh restriction on attachment upload

I have a situation, in which I want to restrict my web page to refresh after I attach a document.
The secnerio is there is some hide when condition written on OnLoad of the Form using javascript, and as soon as the form loads the hide when is active but below that we have more hide when on the basis of selection of a drop down, that is also working, but if I attach a document the web page refreshes and the onload triggers, which further enables the first hide-whne and then again I have to select from drop-down to enable the next hide-when.
Please help if we can restrict web-page refresh after attachment upload.
It sounds like the problem might be more that you have to re-select the drop-down to get the hide-when on that to work after a refresh ? That is, the value is already selected, so there's no change, so the hide-when isn't triggered ?
If so, you probably need to package up the drop-down's hide-when code into a function (if it isn't aleready) and always call that during onload so that if the page refreshes, all hide-when is honoured.
That's assuming the hide-when resulting form the drop-down change is also in Javascript. If it isn't and you have "Refresh fields on keyword change" ticked in the Notes Designer field's properties, then that's what's causing the second refresh, and your best best would be to un-tick that peoperty and simulate the resulting hide-when using javascript, with an onchange event on the drop-down.

Restore dynamic Telerik RadWindows on next postback

I'm doing some ASP using Telerik.
On my page there are 2 buttons called Create Window and Postback. The Create Window button created a new RadWindow dynamically on it's click event (client-side) by using window.radopen(). The Postback button simply does a postback. My problem is that, the windows get lost after every postback. What can I do to make my RadWindows to remain opened after a postback, including its content and position.
If there is no built-in function to restore my dynamic RadWindows, please tell me how to save current windows content to manually load it on the next postback. I thought of using a Hidden control to save my RadWindow position and content, but how can I do that (it's content is a user control with plentiful textboxes, and i don't want my customer to re-type all the textboxes).
The RadWindows are generated via JavaScript when they are first shown. You can easily check this via your developer plugin of choice. Once you show them they create their wrapper div as a direct child of the form element. This means that they have no server-side rendering and thus cannot be persisted on the server across postbacks.
What you can do is use AJAX - have the button perform an AJAX request that will update the needed content of the page, but will leave the RadWindows out of the update. Check out this help article where they explain how to use AJAX with a RadWindow: http://www.telerik.com/help/aspnet-ajax/radwindow-ajaxifying.html.

Categories