I want to make reply control on the Reply button click - c#

I wan to create reply control for the web site in which
if user click on the Reply button then he or she get textbox and button and after clicking on that button the textbox value is insert to the DataBase
I already write one script
the script is like this
Click me!
but this script give me textbox for the 2 to 3 second and after page post back the textbox and button is disappear
so some body help if its possible

You should disable the AutoPostBack property (not sure on the name by heart) on the button which calls your script.
This way, your button will only perform it's action on client-side, and not refresh the page.

Related

Is it possible (or something similar) to disable a button control from a calendar control when the selection is changed on the client side?

I'm not sure if this is possible but I'm looking for a solution that would give a similar effect. I have a calendar control on an asp.net (C#) page along with a button.
Here is some background as to how the page works: When the user selects a date range, there is a post back that shows data and also populates a few drop down boxes with data relevant to the selected date ranges. The dropdown boxes are used to filter the data, for example, the user could choose a specific customer to view data for. After the user selects filters from the drop down boxes, they would click the button to update the page with the filtered data. Alternatively, if they did not select a date and the button is clicked, the selected date range is assumed to be this week. The button is needed because we would prefer not to do multiple database calls if the user wants to use more than one filter from the dropdowns.
With that said, I want to be able to prevent each of these controls from calling another post back if there is already one in progress for the other control. I've seen disabling a button by doing this:
<asp:Button ID = "ShowDataButton" runat="server"
OnClientClick="this.disabled = true;"
UseSubmitBehavior = "false"
onclick="ShowDataButton_Click"
Text = "Show Data"/>
Is there a similar property for a Calendar control that would allow me to disable the button control? Something like, OnClientSelectionChanged = "ShowDataButton.disabled = true;" From what I've researched so far, I'm not too hopeful that this exists. If it doesn't, is there another way that I could accomplish something similar? When I try to add ShowDataButton.Enabled = false; to the OnSelectionChanged event method in the code behind, the button doesn't get disabled until after the postback is finished, which I should have expected. Without something like this occurring, the calendar control ends up returning DateTime.MinValue if the user selects a date and then immediately clicks the button (as the post back takes a few seconds to complete). Any ideas or suggestions would be greatly appreciated.
Your OnClientClick property should actually call a javascript client-side, and then in the javascript you would need to do any actions you desire (eg disable a button, change its style to hide it, etc)

Get the Rad button that were clicked after Post Back

I'm using telerik Grid which has a command button that adds new row/record or another command button that edits selected row/record.
Each grid is inside a twitter bootstrap tab content (Yes, I didn't use telerik tab). What is happening is that when one of buttons that I mentioned above clicked, I expect the tab that contains that button be active at page load.
So is there anyway to get that button so I can use it to activate the proper tab? (ID of that button is enough for me, I will do the rest with jQuery)
Every control that posts back, in an ASP.NET web forms world, sets the __EVENTTARGET and __EVENTARGUMENT (if there is an argument) form values. The __EVENTTARGET form variable has the client ID of the button, so that might be the optimal way. If it's within the grid, I'm not sure, but the __EVENTTARGET may either be the button or grid ID.

C# asp.net Maintain tab index after asynchronous postback ontextchanged

Ok, so I've researched this to the end of the earth and can't seem to find a solution that works.
I have a C# application, which is basically a web form made up of radio button lists and text boxes in an update panel. The form has multiple 'sections', each of which the user submits when completed. Each control performs a postback. This is because if the user modifies a section after completing it, the 'section saved' label needs to disappear.
This all works well, except the postbacks lose the tab order of the controls. I have found code examples that save the last control that had focus, which works well for the radio button lists, but because the text boxes post back when a user tabs to the next control (not modifies the text), it doesn't select the next control. The user has to hit tab again and it jumps to the third text box, not the second because technically, the second text box is what had focus after the initial postback. I hope this makes sense.
Any ideas? I can post code if required.
I should probably also add that this page is within a frame of our community portal.

how to cancel customvalidators action?

I have a webform with a textbox and 3 buttons (add, save and cancel), I'm learning how to use customvalidators (ASP.NET 4.0).
Once the page is loaded, you can only see the add button, after you click on it you can see the textbox and the other 2 buttons.
If textbox is empty I can't save the record (I get this done successfully with customvalidator and javascript, it shows me the error message "textbox can not be left empty"), but what happens if I don't want to save the record anymore and want to cancel instead (by clicking on the cancel button while textbox is still empty)?
I get the customvalidator error "textbox can not be left empty". I have to type something i it so I can do what i need.
Any suggestions?
Thanks in advance
For Cancel button set the attribute CausesValidation="false". That is it...

passing data from Ajax Modal popup extender to a textbox on the asp.net page

I have a Ajax modal popup that displays a set of options for the user. On submit button click event on the ajax modal popup, i need to pass the user selected data back to a text box on the user control (which has the modal pop up) on the calling page.
Structure/flow is as follows. There is a page and two user controls. One is a search control that has another user control that contains the user options. The master page has the search user control. When the user chooses an option in a dropdownlist in the search control, it does a mpe.Show of the user control with options. User makes his selections and hit submit button. In the button click event in the popup, i delegate an event back to the search user control which tries to set the value in one of its text boxes. Everything is going fine until this step and i can see the value but the text box never changes. It seems like the user control is already rendered and the changes are ignored. Any idea how I can get around this?
In short, how to get back the data to a control from an Ajax modal popup.
Use jquery - when the user clicks a button on the modal - use jquery to set the value field to be the data that the user has selected.
e.g.
$('#modalButton').click(function() {
var userData = $('#tbUserData').val();
$('#textBoxElsewhere').val(userData);
});
for anybody's future reference, i did a work around for this. What was happening is that, on the final button click postback, the page/parent user control load events run first and then the button click event.. so the changes that were being made in the button click event did not make it back to the parent user control on the page.. i had to add a middle step to display the user selections for approval and force the user to hit a final confirmation hit. On that post back, the changes were already available for the parent user control, and not have to wait for the button click event to trigger to grab the data. I'm sure there is a better way to do this but this is what I could come up with.

Categories