Different popups for different textbox edits, possible? - c#

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.

Related

How do I display the value in the Textbox

How do I display Price value($) in textbox next to a label when user checks the radio button, select one of item from listBox, and then clicks the button?
Is there way to do it on the form1.cs[Design] using the properties? Or do I need to set them up in code level?
listBox item example
EDIT: Solved this in Code-level.
I don't think you can do it without any code.
Also I'd recommend you to check out this page - just a few simple rules can make your chances to get a good answer on this site much better.
And there is not much of coding needed to solve your problem. Take a look on the Events tab in Property view in form designer. A few event handlers to process user input and some fields inside your class to store the data - I assume it is not some serious business app you're dealing with, so all the code you need for this to work would be like 20 lines tops -)

To provide confirmation message in web page only if any change is done on the page

I want to show a confirmation message on click of cancel button and then redirect to another page. But the confirmation message should come only if any change has been done on the page.
Please can anyone help on this. Is it possible to achieve this at client side or at server side without comparing data ?
Thanks in advance.
I'm guessing you could have a scenario where:
A form is populated with values and each form item that you are tracking for changes also has a corresponding hidden field.
If the user clicks submit = great, but if the user clicks cancel you want to loop through each form item, comparing it to it's original value stored in the hidden field. If a change is detected you want to show a pop-up window informing the user that if they cancel their changes will lost - or something like that.
You can do all this on the client. JQuery, or Knockout (which I would use) or Backbone (I don't know this one tbh) should all provide a neat way to achieve this.
If you can't have hidden fields you might want to send the new values to the server in an Ajax post, get the server to pull the original values, compare and send back an appropriate response to the client. I'm sure there are other ways too*.
edit: like pop the original values in an array via Javascript, then compare them. Anyway, I'm sure you get the idea :)
This could be accomplished using jquery you would need to compare data since you want the message to come up when the cancel button is clicked.
jquery reference

Displaying error message without postback?

I got this an asp.net 3.5 page that and I have few tabs (telerik tabs control with pageview) and I have panel on the top of the page and inside that has a label control displaying error message if it's any.
At the moment, if I want to display this, at the end of the event clicked button for instance, I have to do a custom URL redirection class to itself passing error message and display the error. BUT the problem with this approach let say you are working on 4th tabs and you click save button inside this then you loose the state of series of control (what's is being choosed, selected, typed etc). The page refreshed and displayed at the first tab again.
I want to display the error and at the same time know the state is for every control on the 4th tabs and automatically goes to 4th tabs. BTW ... this validation is done through server level.
I am appreciated your feedback/suggestion.
Thanks
I see several approaches here:
Make an ajax call with data to validate and show error message basing on its result.
Recover your control state after post back, you will need to write some client logic that will analyze url for some parameter after "#", e.g. http://my-site.com/tabs.aspx#4. Your script will know that you need 4-th tab.
You can try to recover your control state on the server, but I don't know how it is possible with telerick tab control.

How to edit individual fields in ASP.NET MVC?

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.

How can I prevent a Checkbox state switch when the user clicks on the text?

I have a list box with Checkboxes in it. I want to prevent the Checkbox from changing its status if the user clicks on the text next to it. I only want it to change if the small box is clicked directly.
Is there any way to do this in windows forms?
Greetings and thanks in advance.
Place the text next to it in a Label, instead of the Text property of the Checkbox. Or you could create your own control which has a Checkbox and a Label. The Text property of the control would then fill the Text in the Label, and you could expose all of the Checkboxes regular properties in your control.
That's fairly non-standard behavior. Users are going to expect to be able to change the checkbox when clicking on its label, and are going to be frustrated, confused, and surprised when it doesn't work. I'd recommend not doing this. I'm not the only one.
(Yes, it's about web design, but many of the concepts are applicable in desktop application design as well.)
You could always not fill in the Text property of the Checkbox and make a completely separate Label control.
Otherwise, you will probably have to do explicit hit testing within the control to see if they hit the box or text. And then you will have to worry about checking the margins, which side the box is on, and other things that can change the position of the box.
I personally was only able to freeze things.
I freeze the check boxes by handling the Click and ItemChecked events,
and change the check state back, when it gets modified.
I use a menu to check/uncheck items and let user decide to use the menu or classic behave.
Cheers, good luck.

Categories