AjaxFileUpload hide upload button and handle manually the upload? - c#

I want to use AjaxFileUpload control:
I am reviewing this, and the functionality I need is to hide the upload button, and save all buttons from another button click event.
Is it possible to do?
According to the properties they show, I dont see an option to hide the button.

Looking at the source html, it seems that doing:
$('.ajax__fileupload_uploadbutton').hide();
Will do the trick of hiding the Upload button. The problem remains, though, as to whether an event is triggered when the user drops the first file or selects it via the Select button. I am sure there's one you can hook into to just call the above line of code (using jQuery on my example).
You can implement the same with pure Javascript.

Related

ASP.Net Only 1 Form Restriction: Should I be using a webpage for everything?

I am forced to use Web Forms in my project, and sadly, Web Forms only allow - If I may - "Strict" Websites to be created.
Whenever you need a Button you need to put it in a form, and then you need another button which has nothing to do with the previous button, and you can't have 2 forms,
And the idea of putting a DIV that fires a server side (C#) method is kind of difficult, okay it may be easy but all I have found are "tricks", not an "official" clean way.
So I have this idea of making a webpage for each action in my websites.
For Example:
Let's say I wanna click on the ARROW that raises the rating of this question, I would put something like this.
HTML
Rate Up
And Some CSS Codes to make it look like a beautiful button...
Okay now this will take me to a page called Rating.aspx with 2 parameters, the first parameter is the ID of the question that I would like to raise its rating, and the second parameter is either UP (+rating) or DOWN(-rating).
On the Page Load method of Rating.aspx, I would update the database, then redirect to the question page.
This will work perfectly, BUT, is it a good approach? is it professional? (put in mind that there will be many actions to preform like that...)
With ASP.NET you better use server controls. Better way of implementing that is using or , that actually renders your anchor tag. But you can attach OnClick event handler to this control (link button) so after clicking there would be automatic POST to server. The same page cycle for the current page will take place (this is called PostBack) and your attached event handler will fire, where you can actually make changes to the database. So you don't even need to create any other pages for tasks like this. Every server control has specific set of events like OnClick for buttons or OnSelectedIndexChanged for dropdown lists. You can even create your own controls or derive from existing ones and create your own events.
Take a look on following links for more information:
Button Click
Event Handling in ASP.NET
ASP.NET Page Life Cycle

Save page data when leaving page

I have an edit form that that has 2 buttons on it, 'Save' (duh) and 'Return To List' ( which performs a save before actually returning ). The problem is the page also has Side Navigation and Top Navigation. So when the user selects any link in those the page doesn't save. Is there a way to perform a save even when Side or Top Navigation links are selected?
Note, this is an MVC3 C# project.
Have you thought about just alerting the user the page hasn't saved yet? Use the onbeforeunload event, display an alert message (or something similar). If they want to save, have them click cancel to stay on the page and save, otherwise proceed without saving.

Creating User Control works with AJAX

I need to create a user control with 3 images: like, dislike and comment buttons. I want to like and dislike button to save some info to the database (liked user and liked object). But i want to work them without reloading the page.
Example scenario:
Like button shows like count if the post has any
User likes a blog post.
Save like process to the DB
Disable like button.
I want to implement this operation via AJAX call to the page in which the control is used, inside of the control. I don't want to implement them separately. When another developer wanted to use this, he/she must use the control just by instantiating. Also, it must be used more than once in a page.
Regards.
Put your buttons inside an update panel in the user control.
This Introduction to the UpdatePanels will get you started.
Then other developers can use you control on any other page without any trouble.
Update panels are server controls that internally make ajax calls and update their contents.
Should work perfectly for what you want.

Implement and editable label?

I would like to present a user with a normal screen with a few fields (Description, Date etc). But I would like them to click the label and without a postback (visible) the label becomes editable, and a 'Save' button appears somewhere.
Once they click save, the data gets saved, and the edit boxes turn back into labels.
Is there a way to implement this?
ASP.Net being used.
There are quite a few edit in place plugins for jQuery. Using one will help you get up and running quickly.
Jeditable is one of the more mature and popular of such plugins. You can find help specifically for using Jeditable with ASP.Net.
Why can't you just use an edit box, and toggle either readonly or enabled?

Asp.net force save on detailsview/formview

When a user is using a Detailsview or Formview in Edit mode, and tries to leave the current page, I want to trap this and force any changes to be saved, just as if the user had clicked on the Update LinkButton. How can I do this?
You can't do this reliably. Consider the scenario if their computer crashes altogether, or they kick the power cord out. There's so many ways that a user can leave a page.
However, you could put in a few safeguards. On any link on the page you could hook up events to do the save before they left. You could also try doing a save after every change in control focus perhaps.
Another thing you can do is hook into the window.onbeforeunload event and give them a confirmation message asking if they're sure they want to leave the page, like SO does when you have an unsaved answer. But there's nothing you can do with this event to force a save.

Categories