PostBack from a User Control

PostBack from a User Control

Post by Jon Byr » Sat, 08 Jun 2002 06:53:57



I have a web form which has a search tool If the user types in a few numbers
and clicks the search button, it loads a user control and retrieves the
search results. The user then clicks on the result they want and it fills
out the remainder of the form. The user control uses the Page_Load
subroutine to query the database and bind to a ListBox control. This works
fine, now I want the user to select an item in the ListBox and fire a
handler to update the data entry form on the web form page. However, the
ListBox control requires the AutoPostBack which is preventing me from
accessing any other event handlers. For example, if I set the
OnSelectedIndexChanged property of the ListBox control, it never fires the
event before the postback occurs which causes the control to dispose.
I tried to override the RaisePostBackEvent but it doesn't work. Any ideas?
Thanks.

Jon

 
 
 

PostBack from a User Control

Post by Jon Byr » Sat, 08 Jun 2002 23:55:11


I think something is awry with this particular page. As a test, I created a
new web form and new user control and performed the same type of procedure
and sure enough, it calls the event handler correctly. However my original
page is still calling the postback first. Any ideas why?

Jon


Quote:> I have a web form which has a search tool If the user types in a few
numbers
> and clicks the search button, it loads a user control and retrieves the
> search results. The user then clicks on the result they want and it fills
> out the remainder of the form. The user control uses the Page_Load
> subroutine to query the database and bind to a ListBox control. This works
> fine, now I want the user to select an item in the ListBox and fire a
> handler to update the data entry form on the web form page. However, the
> ListBox control requires the AutoPostBack which is preventing me from
> accessing any other event handlers. For example, if I set the
> OnSelectedIndexChanged property of the ListBox control, it never fires the
> event before the postback occurs which causes the control to dispose.
> I tried to override the RaisePostBackEvent but it doesn't work. Any ideas?
> Thanks.

> Jon


 
 
 

PostBack from a User Control

Post by Jon Byr » Sun, 09 Jun 2002 01:41:17


Ok, I have more info.
If I have the Page.LoadControl in the Sub_Load portion of the aspx page,
everything works fine. However if I load the control within an event handler
somewhere else, the control does not reload after the post back. The flow of
control should be:

User types in characters and clicks the search button

The control is loaded on the right hand side which brings up a listbox
showing the query results

The user selects an item from the list box and this updates the form fields
on the left hand side

The control with the listbox goes away

So i don't want the control to be loaded each time the aspx page is loaded,
just whenever the user clicks that search button.

How can I complete the processing within the control before reposting the
aspx page?

Thanks.

Jon

> I think something is awry with this particular page. As a test, I created
a
> new web form and new user control and performed the same type of procedure
> and sure enough, it calls the event handler correctly. However my original
> page is still calling the postback first. Any ideas why?

> Jon



> > I have a web form which has a search tool If the user types in a few
> numbers
> > and clicks the search button, it loads a user control and retrieves the
> > search results. The user then clicks on the result they want and it
fills
> > out the remainder of the form. The user control uses the Page_Load
> > subroutine to query the database and bind to a ListBox control. This
works
> > fine, now I want the user to select an item in the ListBox and fire a
> > handler to update the data entry form on the web form page. However, the
> > ListBox control requires the AutoPostBack which is preventing me from
> > accessing any other event handlers. For example, if I set the
> > OnSelectedIndexChanged property of the ListBox control, it never fires
the
> > event before the postback occurs which causes the control to dispose.
> > I tried to override the RaisePostBackEvent but it doesn't work. Any
ideas?
> > Thanks.

> > Jon

 
 
 

1. Creating Instances of User Controls Programmatically Cause To Lose The Control On PostBack

Hi,

I've designed a webusercontrol and loaded it programmatically to a webform.
Everything works fine, except it will disappear when the page is postback.
I've try some methods like SaveViewState and implemented the IStateManager
to the control class,
but it didn't solve my problem.
Can someone tell me how I can prevent my usercontrol from disappearing?

TIA
Adnan

2. need help

3. User Control loses child controls value in case of postback.

4. POA implementation

5. Web user controls -- controlling when postback events fire

6. ??.???.??...

7. Nested User Control Repeater Data Lost On Postback

8. 3/160: attach? disk to scsi tape controller

9. How do I tell what is causing a postback in a web user control?

10. Disappearing values of a user control after a postback...

11. Problems with hidden data field postback in User controls

12. User Control - PostBack Event

13. Disappearing values of a user control after a postback...