I have a chart control and I want to refresh it when a user presses a button, but without refreshing the entire page.
Inside your controller action use the following code.
FormControls.{YourChartId}.Refresh();
Related
I am trying to customize the create user Wizard control in asp. What it does is redirecting me to a continue page after creating the user, but I want a custom page to be displayed after creating a page.... What can I do?
Handle CreatedUser event and then Response.Redirect()
or play with control's properties:
ContinueDestinationPageUrl Gets or sets the URL of the page that the user will see after clicking the Continue button on the success page.
FinishDestinationPageUrl Gets or sets the URL that the user is redirected to when they click the Finish button.
I have a GridView on PageA, I wish to be able to call the DataBind() method of the GridView from PageB?
Basically PageB is a form which will be contained in a pop up control, when the user fills in the fields of the form on PageB and submits it I will close the pop up control, then I want to refresh the GridView on the parent page (PageA), how would I go about doing that?
Write a javascript function on Page A like RefreshGrid, you can write various ways to refresh grid from this javascript function e.g.
1) put your grid inside an update panel and create a trigger button control on that update panel , call this trigger control's click event in javascript , this will partial post back the page and refresh the update panel. There are other ways too..
2) From popup on popup close button, write following line
window.opener.RefreshGrid(); window.close();
Thats it.
If you want to pass any parameter you can pass through as argument to RefreshGrid function.
Still there are many ways , this is the one I use.
I have an aspx page that is wrapped with an UpdatePanel control, users can post comments and delete them later, when the user clicks the delete for the first time it deletes successfully but if he wants to delete another comment, it works only after two clicks on the button.
the delete button is inside a web user control that is added dynamically at run time.
Any ideas?
Thanks.
I had a bit different problem. The control event did not work at all after AJAX post back. Here is the possible solution to your problem - http://sharepointtechie.blogspot.com/2011/04/click-event-stopped-firing-after-ajax.html
Please register that control during page load event of the control..
So if you are calling usercontrol1 dynamically during the runtime..
then on the page load event of usercontrol.ascx you should have
this.id="xyz";
try this... It did some miracle for us...
Hope this works for you too
The situation:
I have user controls with buttons that have hooked events. Controls with events need to be initialized in Page_Load or earlier.
I wish to spawn these user controls dynamically by clicking an Add button.
It is important to remember that events, such as click events, are not fired until just before Page_LoadComplete.
Broken Solution A:
Page_Load: Dynamically create an Add button, hook click event.
User clicks on the Add button, triggers postback.
Page_Load: Creates the Add button as usual, and hooks click event.
Page_Load: Doesn't know that the Add button has been clicked yet, so it doesn't know to spawn the user control!
AddButton_Click: Page finally aware that a new user control should be added upon the next Page_Load.
User cannot see the control they added, because another Page_Load has been triggered.
User reloads the page by clicking a button, refreshing the page, etc.
Page_Load: Creates Add button, and hooks click event. Now aware of added user control, creates user control. Hooks events within the user control.
User clicks on button within user control, triggers just fine.
Result: User has clicked to Add a new user control, the server is aware that the control should exist, but the user does not see it until they trigger the page to load again (by clicking another button, or refreshing, etc).
Naturally, I took a look at the life-cycle, and see that Page_LoadComplete occurs after events, so if I place any event-dependent code in Page_LoadComplete, all should be well?
Broken Solution B:
Page_LoadComplete: Dynamically create an Add button, hook click event.
User clicks on the Add button, triggers postback.
Page_LoadComplete: Creates the Add button as usual, and hooks click event.
AddButton_Click: Page aware that a new user control should be added upon the next Page_LoadComplete.
Page_LoadComplete: Aware of the button click, dynamically adds the control, with its own internal button click event.
User clicks on button within the added user control, but it does not trigger!!
Result: Everything works great, except the button within the added user control is inert.
The conundrum is: I need controls to spawned by a button click, which means I need to put my Controls.Add(...) code in Page_LoadComplete. Inversely, I need the controls being added to have working events, which means the Controls.Add(...) code need to be in Page_Load. I have a perfect dichotomy.
The only janky solution I can think of is taking solution A and forcing the page to reload manually after clicking the Add button, which is a waste of bandwidth and processing.
This might not be the best practice, but you can check Request.Form for the evidence of add button click during the Page_Init event and add the controls there. It should solve your problem.
I have a page with a user control which gets some data updated via a modal popup. Upon clicking "ok" on the modal popup - the new data is being written to the database - but the base page doesnt "reload" to show the updated data. How do I get that to happen?
1) Don't set the OKControlID property on the ModalPopupExtender.
2) In your Page_Load, set OkButton.OnClientClick = string.Format("$find('{0}').hide();", modalPopupExtender1.ClientID);
Explanation:
Setting the OkControlID stops the button from posting back. Instead, manually use javascript to hide the extender, which will allow the button to post the form.
You'll either have to update that control using ajax, or you could just do a Response.Redirect(assuming your modal is .net, or document.location if js) back to your page after your data has been updated.
Make sure the "Ok" button in your modal popup is causing a postback. If you want it to be ajax-enabled, make sure to put it inside of an update panel.