Showing posts with label various. Show all posts
Showing posts with label various. Show all posts

Wednesday, March 28, 2012

Modal Popup events not responding

I have a modal popup control that is created dynamically along with various other controls on Page_Init. Actually it's a user control created dynamically, and part of that user control is the modal popup.

Inside the modal popup is basically just a grid view with some hyperlink columns. The problem is that none of the links ever seem to respond. The popup is shown by a serverside call to the Show() method.

I experimented and put a few buttons and various other controls, and while the button animates like it's been pressed, no server code fires. This happens reguardless of the control type; radiobuttons won't even check. This occurs in controls both inside and outside of the gridview.

Anyone run into something similar with a dynamically created modal popup?

When the controls are being created dynamically, are you attaching events to the objects that will be posting back (ie the modal popup window). I have a similar situation where I have a user control that dynamically creates buttons. The buttons did not work until I added a event handler once I created them. When you add conntrols to a page, this is done automatically, but If you create a control dynamically, you must tell the page what to do with its events when they are raised. Make sence?

-Alan


Yes, it makes sense. The standard events that are tied into the controls, Page_Load, Page_PreRender, etc. all fire fine at the right times. It's only UI events like Click that don't respond on the server side. I can get them to execute javascript (of course) but I'd like to avoid having to hack together a callback function just to get a button working. Besides wiring the buttons/links/etc with events directly from the aspx page, I've tried adding the controls dynamically also (within the dynamically created user control housing the modalpopup) and then wiring them to the events.

Adding the controls that way in the user control's Load, and Init events both yield the same results. The code gets run and the controls get created, but they do not respond to UI events.

Wednesday, March 21, 2012

ModalPanel - How can I us AJAX instead of postback to update database ?

I'm new to AJAX and this suite of tools. I have a page that when a user clicks a link button my ModalPanel with various input fields appears. When the user clicks the okay button I want to make an async call instead of having the page post back. I need to be able to call one of my business objects defined in C# so what is the best way to do this?

If you can provide details or even a small example I would appreciate it.

My code behind method looks like this:

void OnClick(...)

{

Broker b = new Broker();

b.name = NameTextBox.Text;

b.account = AccountTextBox.Text;

b.Save();


}

Why not just wrap the modalpopup in an updatepanel and let the page postback? It is easier then to have access to the server controls from the form and have full interaction with the other page elements during the postback in case you want to update other stuff on the page.

What benefits are you looking for by not posting back?

Jason