Hi,
I have created a web page which includes a place holder. I also have a
dropdown list in that webpage. when I select one of the choices in that
dropdown list, It will load a user control into the place holder. This is
done dynamically based on the choice they selected. This user control has a
datagrid in it that supports paging. When I click on the next or prev buttons
of the datagrid in a user control it should display the next page results.
but it is not doing so. I am not knowing how to call the PageIndexChanged
event of the user control from the webpage. could anyone show me a code
sample to do that? I am using VB.NET for this.
Thanks,
Sridhar. 9 2208
Dynamically loading controls must be done during the Page.Init event handling
(page initialization stage) otherwise they would lose they ViewState and
their events would not fire. So if you added a control based on a
SelectedIndexChanged, it is added late in the page lifecycle and you have to
persist a condition that allows you to reload it during the page.init event
handling, otherwise no response would happen to any of its events.
For a simple demo on this concept: http://www.societopia.net/Samples/Dy...dControls.aspx
For a clear explanation of the page life cycle: http://msdn.microsoft.com/library/de.../viewstate.asp
--
[note: if this post answers your question, you can mark it as an answer
using the web-based newsreader functions]
-----
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
"Sridhar" wrote: Hi,
I have created a web page which includes a place holder. I also have a dropdown list in that webpage. when I select one of the choices in that dropdown list, It will load a user control into the place holder. This is done dynamically based on the choice they selected. This user control has a datagrid in it that supports paging. When I click on the next or prev buttons of the datagrid in a user control it should display the next page results. but it is not doing so. I am not knowing how to call the PageIndexChanged event of the user control from the webpage. could anyone show me a code sample to do that? I am using VB.NET for this.
Thanks, Sridhar.
Dynamically added controls need to be readded on postback. If you don't
add it back, how can an event ever be fired for it, it doesn't exist!.
You can use Denis Bauer's DynamicControlsPlaceholder (free): http://www.denisbauer.com/ASPNETCont...aceholder.aspx
which automatically re-adds dynamic controls on postback, or you can do it
yourself. Here's a dummy example:
sub Page_Load()
if Page.IsPostBack AndAlso not ViewState("controlToReload) is nothing then
plc.Controls.Add(cstr(ViewState(controlPath)))
end if
end sub
sub selectedindexchange(..)
string controlPath = "mycontrol.ascx"
plc.Controls.Add(Page.LoadControl(controlPath))
ViewState.Add("controlToReload", controlPath)
end sub
--
MY ASP.Net tutorials http://www.openmymind.net/
"Sridhar" <Sr*****@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com... Hi,
I have created a web page which includes a place holder. I also have a dropdown list in that webpage. when I select one of the choices in that dropdown list, It will load a user control into the place holder. This is done dynamically based on the choice they selected. This user control has a datagrid in it that supports paging. When I click on the next or prev buttons of the datagrid in a user control it should display the next page results. but it is not doing so. I am not knowing how to call the PageIndexChanged event of the user control from the webpage. could anyone show me a code sample to do that? I am using VB.NET for this.
Thanks, Sridhar.
Philip:
This question gets asked all the time, imma keep ur links and pass them off
as my own helpfulness next time! HAR!
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:A1**********************************@microsof t.com... Dynamically loading controls must be done during the Page.Init event handling (page initialization stage) otherwise they would lose they ViewState and their events would not fire. So if you added a control based on a SelectedIndexChanged, it is added late in the page lifecycle and you have to persist a condition that allows you to reload it during the page.init event handling, otherwise no response would happen to any of its events.
For a simple demo on this concept: http://www.societopia.net/Samples/Dy...dControls.aspx
For a clear explanation of the page life cycle: http://msdn.microsoft.com/library/de.../viewstate.asp
-- [note: if this post answers your question, you can mark it as an answer using the web-based newsreader functions] ----- HTH, Phillip Williams http://www.societopia.net http://www.webswapp.com
"Sridhar" wrote:
Hi,
I have created a web page which includes a place holder. I also have a dropdown list in that webpage. when I select one of the choices in that dropdown list, It will load a user control into the place holder. This is done dynamically based on the choice they selected. This user control has a datagrid in it that supports paging. When I click on the next or prev buttons of the datagrid in a user control it should display the next page results. but it is not doing so. I am not knowing how to call the PageIndexChanged event of the user control from the webpage. could anyone show me a code sample to do that? I am using VB.NET for this.
Thanks, Sridhar.
Hi
Thanks for the reply. But the problem is I am getting the control name
dynamically and loading it dynamically. In that case how would I know which
events shoud I add?
Thanks,
Sridhar.
"Phillip Williams" wrote: Dynamically loading controls must be done during the Page.Init event handling (page initialization stage) otherwise they would lose they ViewState and their events would not fire. So if you added a control based on a SelectedIndexChanged, it is added late in the page lifecycle and you have to persist a condition that allows you to reload it during the page.init event handling, otherwise no response would happen to any of its events.
For a simple demo on this concept: http://www.societopia.net/Samples/Dy...dControls.aspx
For a clear explanation of the page life cycle: http://msdn.microsoft.com/library/de.../viewstate.asp
-- [note: if this post answers your question, you can mark it as an answer using the web-based newsreader functions] ----- HTH, Phillip Williams http://www.societopia.net http://www.webswapp.com
"Sridhar" wrote:
Hi,
I have created a web page which includes a place holder. I also have a dropdown list in that webpage. when I select one of the choices in that dropdown list, It will load a user control into the place holder. This is done dynamically based on the choice they selected. This user control has a datagrid in it that supports paging. When I click on the next or prev buttons of the datagrid in a user control it should display the next page results. but it is not doing so. I am not knowing how to call the PageIndexChanged event of the user control from the webpage. could anyone show me a code sample to do that? I am using VB.NET for this.
Thanks, Sridhar.
If your control is an ascx that you load using the LoadControl method http://msdn.microsoft.com/library/de...ntroltopic.asp
then you have to redo that LoadControl method in the Page_init upon postback.
This should take care of the all the event handling that you have defined in
your ascx control.
--
[note: if this post answers your question, you can mark it as an answer
using the web-based newsreader functions]
-----
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
"Sridhar" wrote: Hi Thanks for the reply. But the problem is I am getting the control name dynamically and loading it dynamically. In that case how would I know which events shoud I add?
Thanks, Sridhar.
"Phillip Williams" wrote:
Dynamically loading controls must be done during the Page.Init event handling (page initialization stage) otherwise they would lose they ViewState and their events would not fire. So if you added a control based on a SelectedIndexChanged, it is added late in the page lifecycle and you have to persist a condition that allows you to reload it during the page.init event handling, otherwise no response would happen to any of its events.
For a simple demo on this concept: http://www.societopia.net/Samples/Dy...dControls.aspx
For a clear explanation of the page life cycle: http://msdn.microsoft.com/library/de.../viewstate.asp
-- [note: if this post answers your question, you can mark it as an answer using the web-based newsreader functions] ----- HTH, Phillip Williams http://www.societopia.net http://www.webswapp.com
"Sridhar" wrote:
Hi,
I have created a web page which includes a place holder. I also have a dropdown list in that webpage. when I select one of the choices in that dropdown list, It will load a user control into the place holder. This is done dynamically based on the choice they selected. This user control has a datagrid in it that supports paging. When I click on the next or prev buttons of the datagrid in a user control it should display the next page results. but it is not doing so. I am not knowing how to call the PageIndexChanged event of the user control from the webpage. could anyone show me a code sample to do that? I am using VB.NET for this.
Thanks, Sridhar.
Hi Karl,
Yes you are right regarding this question being frequently asked. (I am
sorry I did not understand the abbreviations you used in your post: imma and
HAR)
Regards,
Phillip
"Karl Seguin" wrote: Philip: This question gets asked all the time, imma keep ur links and pass them off as my own helpfulness next time! HAR!
Karl -- MY ASP.Net tutorials http://www.openmymind.net/
"Phillip Williams" <Ph**************@webswapp.com> wrote in message news:A1**********************************@microsof t.com... Dynamically loading controls must be done during the Page.Init event handling (page initialization stage) otherwise they would lose they ViewState and their events would not fire. So if you added a control based on a SelectedIndexChanged, it is added late in the page lifecycle and you have to persist a condition that allows you to reload it during the page.init event handling, otherwise no response would happen to any of its events.
For a simple demo on this concept: http://www.societopia.net/Samples/Dy...dControls.aspx
For a clear explanation of the page life cycle: http://msdn.microsoft.com/library/de.../viewstate.asp
-- [note: if this post answers your question, you can mark it as an answer using the web-based newsreader functions] ----- HTH, Phillip Williams http://www.societopia.net http://www.webswapp.com
"Sridhar" wrote:
Hi,
I have created a web page which includes a place holder. I also have a dropdown list in that webpage. when I select one of the choices in that dropdown list, It will load a user control into the place holder. This is done dynamically based on the choice they selected. This user control has a datagrid in it that supports paging. When I click on the next or prev buttons of the datagrid in a user control it should display the next page results. but it is not doing so. I am not knowing how to call the PageIndexChanged event of the user control from the webpage. could anyone show me a code sample to do that? I am using VB.NET for this.
Thanks, Sridhar.
Thank you so much. It is working now.
"Karl Seguin" wrote: Dynamically added controls need to be readded on postback. If you don't add it back, how can an event ever be fired for it, it doesn't exist!.
You can use Denis Bauer's DynamicControlsPlaceholder (free): http://www.denisbauer.com/ASPNETCont...aceholder.aspx which automatically re-adds dynamic controls on postback, or you can do it yourself. Here's a dummy example:
sub Page_Load() if Page.IsPostBack AndAlso not ViewState("controlToReload) is nothing then plc.Controls.Add(cstr(ViewState(controlPath))) end if end sub
sub selectedindexchange(..) string controlPath = "mycontrol.ascx" plc.Controls.Add(Page.LoadControl(controlPath)) ViewState.Add("controlToReload", controlPath) end sub -- MY ASP.Net tutorials http://www.openmymind.net/
"Sridhar" <Sr*****@discussions.microsoft.com> wrote in message news:A2**********************************@microsof t.com... Hi,
I have created a web page which includes a place holder. I also have a dropdown list in that webpage. when I select one of the choices in that dropdown list, It will load a user control into the place holder. This is done dynamically based on the choice they selected. This user control has a datagrid in it that supports paging. When I click on the next or prev buttons of the datagrid in a user control it should display the next page results. but it is not doing so. I am not knowing how to call the PageIndexChanged event of the user control from the webpage. could anyone show me a code sample to do that? I am using VB.NET for this.
Thanks, Sridhar.
imma = im going to
and HAR is my pirate laugh...HAR HAR!
Karl ;)
--
MY ASP.Net tutorials http://www.openmymind.net/
"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:A9**********************************@microsof t.com... Hi Karl,
Yes you are right regarding this question being frequently asked. (I am sorry I did not understand the abbreviations you used in your post: imma and HAR)
Regards,
Phillip
"Karl Seguin" wrote:
Philip: This question gets asked all the time, imma keep ur links and pass them off as my own helpfulness next time! HAR!
Karl -- MY ASP.Net tutorials http://www.openmymind.net/
"Phillip Williams" <Ph**************@webswapp.com> wrote in message news:A1**********************************@microsof t.com... > Dynamically loading controls must be done during the Page.Init event > handling > (page initialization stage) otherwise they would lose they ViewState > and > their events would not fire. So if you added a control based on a > SelectedIndexChanged, it is added late in the page lifecycle and you > have > to > persist a condition that allows you to reload it during the page.init > event > handling, otherwise no response would happen to any of its events. > > For a simple demo on this concept: > http://www.societopia.net/Samples/Dy...dControls.aspx > > For a clear explanation of the page life cycle: > http://msdn.microsoft.com/library/de.../viewstate.asp > > -- > [note: if this post answers your question, you can mark it as an answer > using the web-based newsreader functions] > ----- > HTH, > Phillip Williams > http://www.societopia.net > http://www.webswapp.com > > > "Sridhar" wrote: > >> Hi, >> >> I have created a web page which includes a place holder. I also have >> a >> dropdown list in that webpage. when I select one of the choices in >> that >> dropdown list, It will load a user control into the place holder. >> This >> is >> done dynamically based on the choice they selected. This user control >> has >> a >> datagrid in it that supports paging. When I click on the next or prev >> buttons >> of the datagrid in a user control it should display the next page >> results. >> but it is not doing so. I am not knowing how to call the >> PageIndexChanged >> event of the user control from the webpage. could anyone show me a >> code >> sample to do that? I am using VB.NET for this. >> >> Thanks, >> Sridhar.
No piracy at all. :-) I believe all information posted on the newsgroup is
free to share. You are quite welcome to do so.
Regards,
Phillip
"Karl Seguin" wrote: imma = im going to and HAR is my pirate laugh...HAR HAR!
Karl ;)
-- MY ASP.Net tutorials http://www.openmymind.net/
"Phillip Williams" <Ph**************@webswapp.com> wrote in message news:A9**********************************@microsof t.com... Hi Karl,
Yes you are right regarding this question being frequently asked. (I am sorry I did not understand the abbreviations you used in your post: imma and HAR)
Regards,
Phillip
"Karl Seguin" wrote:
Philip: This question gets asked all the time, imma keep ur links and pass them off as my own helpfulness next time! HAR!
Karl -- MY ASP.Net tutorials http://www.openmymind.net/
"Phillip Williams" <Ph**************@webswapp.com> wrote in message news:A1**********************************@microsof t.com... > Dynamically loading controls must be done during the Page.Init event > handling > (page initialization stage) otherwise they would lose they ViewState > and > their events would not fire. So if you added a control based on a > SelectedIndexChanged, it is added late in the page lifecycle and you > have > to > persist a condition that allows you to reload it during the page.init > event > handling, otherwise no response would happen to any of its events. > > For a simple demo on this concept: > http://www.societopia.net/Samples/Dy...dControls.aspx > > For a clear explanation of the page life cycle: > http://msdn.microsoft.com/library/de.../viewstate.asp > > -- > [note: if this post answers your question, you can mark it as an answer > using the web-based newsreader functions] > ----- > HTH, > Phillip Williams > http://www.societopia.net > http://www.webswapp.com > > > "Sridhar" wrote: > >> Hi, >> >> I have created a web page which includes a place holder. I also have >> a >> dropdown list in that webpage. when I select one of the choices in >> that >> dropdown list, It will load a user control into the place holder. >> This >> is >> done dynamically based on the choice they selected. This user control >> has >> a >> datagrid in it that supports paging. When I click on the next or prev >> buttons >> of the datagrid in a user control it should display the next page >> results. >> but it is not doing so. I am not knowing how to call the >> PageIndexChanged >> event of the user control from the webpage. could anyone show me a >> code >> sample to do that? I am using VB.NET for this. >> >> Thanks, >> Sridhar. This discussion thread is closed Replies have been disabled for this discussion. Similar topics
18 posts
views
Thread by Christopher W. Douglas |
last post: by
|
5 posts
views
Thread by Russell Smallwood |
last post: by
|
15 posts
views
Thread by Amit D.Shinde |
last post: by
|
5 posts
views
Thread by Steve |
last post: by
|
2 posts
views
Thread by Developer_Software |
last post: by
|
3 posts
views
Thread by c676228 |
last post: by
|
1 post
views
Thread by EricRybarczyk |
last post: by
|
2 posts
views
Thread by weboweb |
last post: by
| | | | | | | | | | | |