Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: User Controls


Message #1 by agamble@t... on Tue, 18 Dec 2001 12:04:45
I'm 99.999% sure that the 'OnServerClick' event is fired before the
Page_Load().  The user clicks on the submit button, which then fires the
'OnServerClick' event.  Once that completes, the page is reloaded, and with
that, it fires the Page_Load() method.

Give that a try and see how it works.

Doug

----- Original Message -----
From: "Alessandro Facchini" <tid3840@i...>
To: "ASPX_Professional" <aspx_professional@p...>
Sent: Tuesday, December 18, 2001 3:41 PM
Subject: [aspx_professional] Re: User Controls


> You can see here:
> http://www.123aspx.com/resdetail.aspx?res=27403
>
> Bye
>
> Alessandro Facchini
>
>
> ----- Original Message -----
> From: <agamble@t...>
> To: "ASPX_Professional" <aspx_professional@p...>
> Sent: Tuesday, December 18, 2001 12:04 PM
> Subject: [aspx_professional] User Controls
>
>
> >
> > I have got a user control which is basically a couple of form fields and
a
> > submit button and all logic is in the code behind for the user control.
> > All it does is insert a new record into a table by calling the event
> > specified in the onserverclick property which is contained within the
user
> > control.
> >
> > This user control is inserted into a aspx page which also includes a
> > datagrid box which is bound to the table which the usercontrol inserts
> > into.
> >
> > The reason I wrote this as a user control is because there is potential
> > for this to be used in numerous places throughout the site.
> >
> > THe problem I have is that If you use the usercontrol to insert a new
> > record into the table then it calls the event in the user control to add
> > the new record and then redisplays the datagrid, however the new record
> > does not appear in the datagrid.
> >
> > The reason for this is because the databind method has not been called
for
> > the datagrid and therefore uses the data held in the view state for the
> > datagrid.
> >
> > The problem I have is calling the databind method on the datagrid in the
> > aspx page.
> >
> > There are a few questions here , mainly I am asking what would be the
best
> > way to do this.
> >
> > So the first thing I thought I could do whas call a routine I wrote in
the
> > aspx page from the user control which binds the datagrid to the
> > datasource. Is it possible to call a function in an aspx page from a
user
> > control?
> >
> > This made me think that maybe this is not the way to do it anyway. As I
> > stated earlier this is to be used in numerous places and it might not
> > always want to bind the results to a datgrid after inserting the record.
> >
> > SO I then thought is there a way that within the user control you can
> > raise an event in the aspx page , which I could then use to rebind the
> > datagrid. Is this possible?
> >
> > Another alternative which Im not sure would work would be to blindly
just
> > rebind the datagrid everytime the page is loaded in the page_load event.
> > But the question here is, is the page_load event executed before the
> > onserver event which was specified on the user control add button. If
this
> > is the case then surely it would bind the datagrid to the datasource
> > before the new record was inserted and then still wouldn't display the
new
> > record in the grid. Am I right or is the onserverclick called before the
> > page_load event.
> >
> > What I would be grateful for is if someone could tell me what the right
> > way would be to go about this scenario. Am I on the right lines or way
> > off.
> >
> > Thanks
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> $subst('Email.Unsub').
>
>
$subst('Email.Unsub').


  Return to Index