How to edit individual fields in ASP.NET MVC? - c#

I want to be able to update fields of my models by showing the values and then having a little "edit" button next to it, which would turn the label into textbox/dropdownlist and the edit button should disappear and instead show a Save and Cancel buttons. The save and cancel buttons should disappear when you click on them or on any other thing in the page (and the edit button should come back) .
I'm pretty sure that this will require some javascript (hopefully it could be done all in jQuery).
Do you have any suggestions (links/tutorials) on how to achieve this?
Thanks!

This article might help you out http://www.appelsiini.net/projects/jeditable
Also, just Google "jquery edit in place" and there should be a lot of articles to help you out.

Related

How do I reset Page life cycle from code behind?

I have a web page that is meant to be a product view for a computer. I have a div next to the product photo that contains the product information. The div is runat="server" and when the user selects a 'customize' button within the div, I have C# in the code behind button event handler that erases the current product information in the div and replaces it with drop down menus for the customization options.
I want to have a "Cancel Customization" button that allows the user to stop customizing and go back to the original product view page. I have tried using Response.Redirect("CurrentPageUrl"); but because I am redirecting to the page I am currently on, I guess it's a postback and not a full life cycle reset. The result is that the page reloads with the div just empty. What I really want to do is reset the page life cycle somehow, so it is as if the 'Customize' button was never clicked and the original page code, including the product info, on the server is completely reinitialized. I have looked around for how to do this but everywhere just seems to recommend Response.Redirect() which as I have said does not produce the desired behavior.
I realize I could just reinsert all of the original product information from the original page but this seems like a lot of code and I figure there must be a way to just re-initialize the Page?
Summary:
Page initializes with div filled with Product Info.
Customize button is clicked, button handler in C# code behind removes contents of div and replaces it with customization options.
desired behavior: 'Cancel customization' button is clicked, page is reloaded so product info is now back in div.
current behavior: 'Cancel customization' button is clicked, Response.Redirect("CurrentPageUrl") is called, page posts back and div is now empty.
I will be checking this post very often for the first few days so please don't hesitate to ask for more info I'll get back to you quickly. I apologize in advance if this question has already been asked, I did spend quite a bit of time looking for answers on S.O before posting this and as I said all I could find were recommendations for Response.Redirect() which is not what I'm looking for. I am developing the site using VS2019 ASP.NET framework web forms if that makes a difference.
Thanks for any answers!

Create "dropdown" comment box within a GridView

I'm very new to ASP.NET and imagine this is possible, but I have a grid view with a handful of columns. One of the columns has a button, that when clicked, I'd like a box to appear below the button (to ensure its visibility) that allows the user to add comments, submit comments, and cancel. I'm not too worried about the last three pieces of functionality yet, but am stuck on just getting the comments box to pop up in the right spot.
My idea functionality would be to have the rows below the clicked button the shift down to leave a space for the comments box, and once it is submitted, to have it disappear and the other rows back in place. The second best solution would be to have a pop-up window.
I must also note that I am on a closed system that cannot have any plugins installed, though it does have jquery.
I can elaborate on my problem if needed.
you can use either Accordion, HoverMenu or ModalPopup. please go to the following link for the demo and select your choice.
AjaxControlToolkit Demo

Toggle button like google places

How can we implement Toggle button like google places
When click on write Review we smile images and sad images
http://maps.google.com/maps/place?cid=7069125495329769622&hl=en-IN
Do you mean, when click on "Write Review" it focus on the review textarea? I would use jquery (see http://api.jquery.com/click/), if you want an easy solution, on the postback just focus on the textbox...

Different popups for different textbox edits, possible?

I have an issue with a popup in Asp.net using AJAX modalpoup extender. Is it possible to show one kind of popup when the user edits few textboxes and the other kind of popup for the remaining textboxes.
I guess it is possible with some javascript function. Could someone help me out?
Ex: Only when txtbox1's value is changed, it should show me popup1 when the save button is clicked. Or else popup2.
Thanks in advance!
This might be something that is limited by the fact that you're using ASP.net's modulapopup. Have you tried looking into jQuery?
For example, you could assign event handlers to the specific buttons/textboxes and have them trigger different events - which you would then handle accordingly, i.e. displaying different popups. Take a look at jQuery UI, specifically their Dialog demo.

How to add gridview into pop up window?

I want to add my grid view into pop up window. My grid view consist of radio buttons.
so i want to select one of radio button and take clicked button's text value to my web page. Any one can tell me to create pop up to my sharepoint web part.
cheers !!!!
Chinthaka
You might have some success using JavaScript. Here's a few threads that cover the basic idea. I'm no jQuery expert, but I'll bet a pretty rock there's a slick, browser-independent way to do it in jQuery.
http://wiki.asp.net/page.aspx/282/passing-value-from-popup-window-to-parent-form39s-textbox/
http://www.plus2net.com/javascript_tutorial/window-child3.php
http://forums.digitalpoint.com/showthread.php?t=35053

Categories