DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Sat, 16 Jun 2007 00:53:22 -0400,    posted on: microsoft.public.dotnet.framework.aspnet.buildingcontrols        back       

Thread Index
  1    Nathan Sokalski
          2    Masudur
          3    Masudur
          4    Masudur
                 5    Nathan Sokalski
                 6    Nathan Sokalski
                 7    Nathan Sokalski
                        8    Cor Ligthert [MVP]
                        9    Cor Ligthert [MVP]
                        10    Cor Ligthert [MVP]
                        11    Miha Markic miha at rthand com
                        12    Miha Markic miha at rthand com
                        13    Miha Markic miha at rthand com
                        14    Nathan Sokalski
                        15    Nathan Sokalski
                        16    Nathan Sokalski
                        17    Cor Ligthert [MVP]
                        18    Cor Ligthert [MVP]
                        19    Cor Ligthert [MVP]
                        20    Cor Ligthert [MVP]
                        21    Cor Ligthert [MVP]
                        22    Cor Ligthert [MVP]


Maintaining the look of dynamically added usercontrols   
I have a page which I dynamically add several usercontrols (*.ascx files) to 
using the following code:


 Public Sub Refresh()
  For Each section As DataRow In Me.GetSections().Rows
   CType(Me.FindControl("admin" & CStr(section("buttontext")).Replace(" ", 
"")), adminsection2).RefreshSection()
  Next
 End Sub

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As 
System.EventArgs) Handles Me.Load
  Dim sections As DataTable = Me.GetSections()
  For Each section As DataRow In sections.Rows
   Me.AddAdminSection(CStr(section("buttontext")))
  Next
  Me.Refresh()
 End Sub

 Private Function GetSections() As DataTable
  Dim sections As New DataTable
  Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext FROM 
subnavigation WHERE buttontext<>'More.' AND category='" & 
Request.QueryString("category") & "' ORDER BY buttonorder", 
System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
  dataadapterSelect.Fill(sections)
  Return sections
 End Function

 Private Sub AddAdminSection(ByVal section As String)
  Dim admin As adminsection2 = 
CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), adminsection2)
  admin.ID = "admin" & section.Replace(" ", "")
  admin.Section = section
  Me.form1.Controls.Add(admin)
 End Sub


My problem is that the controls are reloaded every time, as you can see from 
the Load event. If I place the following line

Me.AddAdminSection(CStr(section("buttontext")))

in an If Not Me.IsPostBack() statement, then it is only loaded the first 
time and I recieve an object does not exist error every time the Refresh() 
method is called (which is reasonably often, because this is for an 
administration page where the user edits DB records). What can I do to 
maintain the look of the dynamically added controls (in other words, how can 
I avoid replacing them with every postback)? If there is any other code you 
need to see that might help, let me know. Thanks.
-- 
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
Date:Sat, 16 Jun 2007 00:53:22 -0400   Author:  

Re: Maintaining the look of dynamically added usercontrols   
On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:

> I have a page which I dynamically add several usercontrols (*.ascx files) to
> using the following code:
>
>  Public Sub Refresh()
>   For Each section As DataRow In Me.GetSections().Rows
>    CType(Me.FindControl("admin" & CStr(section("buttontext")).Replace(" ",
> "")), adminsection2).RefreshSection()
>   Next
>  End Sub
>
>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Load
>   Dim sections As DataTable = Me.GetSections()
>   For Each section As DataRow In sections.Rows
>    Me.AddAdminSection(CStr(section("buttontext")))
>   Next
>   Me.Refresh()
>  End Sub
>
>  Private Function GetSections() As DataTable
>   Dim sections As New DataTable
>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext FROM
> subnavigation WHERE buttontext<>'More.' AND category='" &
> Request.QueryString("category") & "' ORDER BY buttonorder",
> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>   dataadapterSelect.Fill(sections)
>   Return sections
>  End Function
>
>  Private Sub AddAdminSection(ByVal section As String)
>   Dim admin As adminsection2 =
> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), adminsection2)
>   admin.ID = "admin" & section.Replace(" ", "")
>   admin.Section = section
>   Me.form1.Controls.Add(admin)
>  End Sub
>
> My problem is that the controls are reloaded every time, as you can see from
> the Load event. If I place the following line
>
> Me.AddAdminSection(CStr(section("buttontext")))
>
> in an If Not Me.IsPostBack() statement, then it is only loaded the first
> time and I recieve an object does not exist error every time the Refresh()
> method is called (which is reasonably often, because this is for an
> administration page where the user edits DB records). What can I do to
> maintain the look of the dynamically added controls (in other words, how can
> I avoid replacing them with every postback)? If there is any other code you
> need to see that might help, let me know. Thanks.
> --
> Nathan Sokalski
> njsokal...@hotmail.comhttp://www.nathansokalski.com/


Hi,

Dynamically loaded controls need to be load after each post back...
other wise dynamically loaded control's event wont work...
Its always a good practice to load the controls in page_init event

Thanks
Masudur
Date:Sat, 16 Jun 2007 06:10:18 -0000   Author:  

Re: Maintaining the look of dynamically added usercontrols   
On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:

> I have a page which I dynamically add several usercontrols (*.ascx files) to
> using the following code:
>
>  Public Sub Refresh()
>   For Each section As DataRow In Me.GetSections().Rows
>    CType(Me.FindControl("admin" & CStr(section("buttontext")).Replace(" ",
> "")), adminsection2).RefreshSection()
>   Next
>  End Sub
>
>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Load
>   Dim sections As DataTable = Me.GetSections()
>   For Each section As DataRow In sections.Rows
>    Me.AddAdminSection(CStr(section("buttontext")))
>   Next
>   Me.Refresh()
>  End Sub
>
>  Private Function GetSections() As DataTable
>   Dim sections As New DataTable
>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext FROM
> subnavigation WHERE buttontext<>'More.' AND category='" &
> Request.QueryString("category") & "' ORDER BY buttonorder",
> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>   dataadapterSelect.Fill(sections)
>   Return sections
>  End Function
>
>  Private Sub AddAdminSection(ByVal section As String)
>   Dim admin As adminsection2 =
> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), adminsection2)
>   admin.ID = "admin" & section.Replace(" ", "")
>   admin.Section = section
>   Me.form1.Controls.Add(admin)
>  End Sub
>
> My problem is that the controls are reloaded every time, as you can see from
> the Load event. If I place the following line
>
> Me.AddAdminSection(CStr(section("buttontext")))
>
> in an If Not Me.IsPostBack() statement, then it is only loaded the first
> time and I recieve an object does not exist error every time the Refresh()
> method is called (which is reasonably often, because this is for an
> administration page where the user edits DB records). What can I do to
> maintain the look of the dynamically added controls (in other words, how can
> I avoid replacing them with every postback)? If there is any other code you
> need to see that might help, let me know. Thanks.
> --
> Nathan Sokalski
> njsokal...@hotmail.comhttp://www.nathansokalski.com/


Hi,

Dynamically loaded controls need to be load after each post back...
other wise dynamically loaded control's event wont work...
Its always a good practice to load the controls in page_init event

Thanks
Masudur
Date:Sat, 16 Jun 2007 06:10:18 -0000   Author:  

Re: Maintaining the look of dynamically added usercontrols   
On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:

> I have a page which I dynamically add several usercontrols (*.ascx files) to
> using the following code:
>
>  Public Sub Refresh()
>   For Each section As DataRow In Me.GetSections().Rows
>    CType(Me.FindControl("admin" & CStr(section("buttontext")).Replace(" ",
> "")), adminsection2).RefreshSection()
>   Next
>  End Sub
>
>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Load
>   Dim sections As DataTable = Me.GetSections()
>   For Each section As DataRow In sections.Rows
>    Me.AddAdminSection(CStr(section("buttontext")))
>   Next
>   Me.Refresh()
>  End Sub
>
>  Private Function GetSections() As DataTable
>   Dim sections As New DataTable
>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext FROM
> subnavigation WHERE buttontext<>'More.' AND category='" &
> Request.QueryString("category") & "' ORDER BY buttonorder",
> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>   dataadapterSelect.Fill(sections)
>   Return sections
>  End Function
>
>  Private Sub AddAdminSection(ByVal section As String)
>   Dim admin As adminsection2 =
> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), adminsection2)
>   admin.ID = "admin" & section.Replace(" ", "")
>   admin.Section = section
>   Me.form1.Controls.Add(admin)
>  End Sub
>
> My problem is that the controls are reloaded every time, as you can see from
> the Load event. If I place the following line
>
> Me.AddAdminSection(CStr(section("buttontext")))
>
> in an If Not Me.IsPostBack() statement, then it is only loaded the first
> time and I recieve an object does not exist error every time the Refresh()
> method is called (which is reasonably often, because this is for an
> administration page where the user edits DB records). What can I do to
> maintain the look of the dynamically added controls (in other words, how can
> I avoid replacing them with every postback)? If there is any other code you
> need to see that might help, let me know. Thanks.
> --
> Nathan Sokalski
> njsokal...@hotmail.comhttp://www.nathansokalski.com/


Hi,

Dynamically loaded controls need to be load after each post back...
other wise dynamically loaded control's event wont work...
Its always a good practice to load the controls in page_init event

Thanks
Masudur
Date:Sat, 16 Jun 2007 06:10:18 -0000   Author:  

Re: Maintaining the look of dynamically added usercontrols   
Isn't there any kind of workaround? I am sure that I am not the first person 
to want to maintain the properties of dynamically loaded usercontrols 
between postbacks. Anybody have any ideas? Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

"Masudur"  wrote in message 
news:1181974218.719890.57440@o11g2000prd.googlegroups.com...

> On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:
>> I have a page which I dynamically add several usercontrols (*.ascx files) 
>> to
>> using the following code:
>>
>>  Public Sub Refresh()
>>   For Each section As DataRow In Me.GetSections().Rows
>>    CType(Me.FindControl("admin" & CStr(section("buttontext")).Replace(" 
>> ",
>> "")), adminsection2).RefreshSection()
>>   Next
>>  End Sub
>>
>>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles Me.Load
>>   Dim sections As DataTable = Me.GetSections()
>>   For Each section As DataRow In sections.Rows
>>    Me.AddAdminSection(CStr(section("buttontext")))
>>   Next
>>   Me.Refresh()
>>  End Sub
>>
>>  Private Function GetSections() As DataTable
>>   Dim sections As New DataTable
>>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext FROM
>> subnavigation WHERE buttontext<>'More.' AND category='" &
>> Request.QueryString("category") & "' ORDER BY buttonorder",
>> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>>   dataadapterSelect.Fill(sections)
>>   Return sections
>>  End Function
>>
>>  Private Sub AddAdminSection(ByVal section As String)
>>   Dim admin As adminsection2 =
>> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), 
>> adminsection2)
>>   admin.ID = "admin" & section.Replace(" ", "")
>>   admin.Section = section
>>   Me.form1.Controls.Add(admin)
>>  End Sub
>>
>> My problem is that the controls are reloaded every time, as you can see 
>> from
>> the Load event. If I place the following line
>>
>> Me.AddAdminSection(CStr(section("buttontext")))
>>
>> in an If Not Me.IsPostBack() statement, then it is only loaded the first
>> time and I recieve an object does not exist error every time the 
>> Refresh()
>> method is called (which is reasonably often, because this is for an
>> administration page where the user edits DB records). What can I do to
>> maintain the look of the dynamically added controls (in other words, how 
>> can
>> I avoid replacing them with every postback)? If there is any other code 
>> you
>> need to see that might help, let me know. Thanks.
>> --
>> Nathan Sokalski
>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>
> Hi,
>
> Dynamically loaded controls need to be load after each post back...
> other wise dynamically loaded control's event wont work...
> Its always a good practice to load the controls in page_init event
>
> Thanks
> Masudur
> 
Date:Sat, 16 Jun 2007 21:54:53 -0400   Author:  

Re: Maintaining the look of dynamically added usercontrols   
Isn't there any kind of workaround? I am sure that I am not the first person 
to want to maintain the properties of dynamically loaded usercontrols 
between postbacks. Anybody have any ideas? Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

"Masudur"  wrote in message 
news:1181974218.719890.57440@o11g2000prd.googlegroups.com...

> On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:
>> I have a page which I dynamically add several usercontrols (*.ascx files) 
>> to
>> using the following code:
>>
>>  Public Sub Refresh()
>>   For Each section As DataRow In Me.GetSections().Rows
>>    CType(Me.FindControl("admin" & CStr(section("buttontext")).Replace(" 
>> ",
>> "")), adminsection2).RefreshSection()
>>   Next
>>  End Sub
>>
>>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles Me.Load
>>   Dim sections As DataTable = Me.GetSections()
>>   For Each section As DataRow In sections.Rows
>>    Me.AddAdminSection(CStr(section("buttontext")))
>>   Next
>>   Me.Refresh()
>>  End Sub
>>
>>  Private Function GetSections() As DataTable
>>   Dim sections As New DataTable
>>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext FROM
>> subnavigation WHERE buttontext<>'More.' AND category='" &
>> Request.QueryString("category") & "' ORDER BY buttonorder",
>> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>>   dataadapterSelect.Fill(sections)
>>   Return sections
>>  End Function
>>
>>  Private Sub AddAdminSection(ByVal section As String)
>>   Dim admin As adminsection2 =
>> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), 
>> adminsection2)
>>   admin.ID = "admin" & section.Replace(" ", "")
>>   admin.Section = section
>>   Me.form1.Controls.Add(admin)
>>  End Sub
>>
>> My problem is that the controls are reloaded every time, as you can see 
>> from
>> the Load event. If I place the following line
>>
>> Me.AddAdminSection(CStr(section("buttontext")))
>>
>> in an If Not Me.IsPostBack() statement, then it is only loaded the first
>> time and I recieve an object does not exist error every time the 
>> Refresh()
>> method is called (which is reasonably often, because this is for an
>> administration page where the user edits DB records). What can I do to
>> maintain the look of the dynamically added controls (in other words, how 
>> can
>> I avoid replacing them with every postback)? If there is any other code 
>> you
>> need to see that might help, let me know. Thanks.
>> --
>> Nathan Sokalski
>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>
> Hi,
>
> Dynamically loaded controls need to be load after each post back...
> other wise dynamically loaded control's event wont work...
> Its always a good practice to load the controls in page_init event
>
> Thanks
> Masudur
> 
Date:Sat, 16 Jun 2007 21:54:53 -0400   Author:  

Re: Maintaining the look of dynamically added usercontrols   
Isn't there any kind of workaround? I am sure that I am not the first person 
to want to maintain the properties of dynamically loaded usercontrols 
between postbacks. Anybody have any ideas? Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

"Masudur"  wrote in message 
news:1181974218.719890.57440@o11g2000prd.googlegroups.com...

> On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:
>> I have a page which I dynamically add several usercontrols (*.ascx files) 
>> to
>> using the following code:
>>
>>  Public Sub Refresh()
>>   For Each section As DataRow In Me.GetSections().Rows
>>    CType(Me.FindControl("admin" & CStr(section("buttontext")).Replace(" 
>> ",
>> "")), adminsection2).RefreshSection()
>>   Next
>>  End Sub
>>
>>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles Me.Load
>>   Dim sections As DataTable = Me.GetSections()
>>   For Each section As DataRow In sections.Rows
>>    Me.AddAdminSection(CStr(section("buttontext")))
>>   Next
>>   Me.Refresh()
>>  End Sub
>>
>>  Private Function GetSections() As DataTable
>>   Dim sections As New DataTable
>>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext FROM
>> subnavigation WHERE buttontext<>'More.' AND category='" &
>> Request.QueryString("category") & "' ORDER BY buttonorder",
>> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>>   dataadapterSelect.Fill(sections)
>>   Return sections
>>  End Function
>>
>>  Private Sub AddAdminSection(ByVal section As String)
>>   Dim admin As adminsection2 =
>> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), 
>> adminsection2)
>>   admin.ID = "admin" & section.Replace(" ", "")
>>   admin.Section = section
>>   Me.form1.Controls.Add(admin)
>>  End Sub
>>
>> My problem is that the controls are reloaded every time, as you can see 
>> from
>> the Load event. If I place the following line
>>
>> Me.AddAdminSection(CStr(section("buttontext")))
>>
>> in an If Not Me.IsPostBack() statement, then it is only loaded the first
>> time and I recieve an object does not exist error every time the 
>> Refresh()
>> method is called (which is reasonably often, because this is for an
>> administration page where the user edits DB records). What can I do to
>> maintain the look of the dynamically added controls (in other words, how 
>> can
>> I avoid replacing them with every postback)? If there is any other code 
>> you
>> need to see that might help, let me know. Thanks.
>> --
>> Nathan Sokalski
>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>
> Hi,
>
> Dynamically loaded controls need to be load after each post back...
> other wise dynamically loaded control's event wont work...
> Its always a good practice to load the controls in page_init event
>
> Thanks
> Masudur
> 
Date:Sat, 16 Jun 2007 21:54:53 -0400   Author:  

Re: Maintaining the look of dynamically added usercontrols   
Nathan,

Probably Ajax,  however I am seriously curious what a usercontrol for ASPNET 
has to do with ADONET.

Cor

"Nathan Sokalski"  schreef in bericht 
news:eTM78JIsHHA.4992@TK2MSFTNGP05.phx.gbl...

> Isn't there any kind of workaround? I am sure that I am not the first 
> person to want to maintain the properties of dynamically loaded 
> usercontrols between postbacks. Anybody have any ideas? Thanks.
> --
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
> "Masudur"  wrote in message 
> news:1181974218.719890.57440@o11g2000prd.googlegroups.com...
>> On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:
>>> I have a page which I dynamically add several usercontrols (*.ascx 
>>> files) to
>>> using the following code:
>>>
>>>  Public Sub Refresh()
>>>   For Each section As DataRow In Me.GetSections().Rows
>>>    CType(Me.FindControl("admin" & CStr(section("buttontext")).Replace(" 
>>> ",
>>> "")), adminsection2).RefreshSection()
>>>   Next
>>>  End Sub
>>>
>>>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>> System.EventArgs) Handles Me.Load
>>>   Dim sections As DataTable = Me.GetSections()
>>>   For Each section As DataRow In sections.Rows
>>>    Me.AddAdminSection(CStr(section("buttontext")))
>>>   Next
>>>   Me.Refresh()
>>>  End Sub
>>>
>>>  Private Function GetSections() As DataTable
>>>   Dim sections As New DataTable
>>>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext FROM
>>> subnavigation WHERE buttontext<>'More.' AND category='" &
>>> Request.QueryString("category") & "' ORDER BY buttonorder",
>>> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>>>   dataadapterSelect.Fill(sections)
>>>   Return sections
>>>  End Function
>>>
>>>  Private Sub AddAdminSection(ByVal section As String)
>>>   Dim admin As adminsection2 =
>>> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), 
>>> adminsection2)
>>>   admin.ID = "admin" & section.Replace(" ", "")
>>>   admin.Section = section
>>>   Me.form1.Controls.Add(admin)
>>>  End Sub
>>>
>>> My problem is that the controls are reloaded every time, as you can see 
>>> from
>>> the Load event. If I place the following line
>>>
>>> Me.AddAdminSection(CStr(section("buttontext")))
>>>
>>> in an If Not Me.IsPostBack() statement, then it is only loaded the first
>>> time and I recieve an object does not exist error every time the 
>>> Refresh()
>>> method is called (which is reasonably often, because this is for an
>>> administration page where the user edits DB records). What can I do to
>>> maintain the look of the dynamically added controls (in other words, how 
>>> can
>>> I avoid replacing them with every postback)? If there is any other code 
>>> you
>>> need to see that might help, let me know. Thanks.
>>> --
>>> Nathan Sokalski
>>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>>
>> Hi,
>>
>> Dynamically loaded controls need to be load after each post back...
>> other wise dynamically loaded control's event wont work...
>> Its always a good practice to load the controls in page_init event
>>
>> Thanks
>> Masudur
>>
>
> 
Date:Mon, 18 Jun 2007 06:59:09 +0200   Author:  

Re: Maintaining the look of dynamically added usercontrols   
Nathan,

Probably Ajax,  however I am seriously curious what a usercontrol for ASPNET 
has to do with ADONET.

Cor

"Nathan Sokalski"  schreef in bericht 
news:eTM78JIsHHA.4992@TK2MSFTNGP05.phx.gbl...

> Isn't there any kind of workaround? I am sure that I am not the first 
> person to want to maintain the properties of dynamically loaded 
> usercontrols between postbacks. Anybody have any ideas? Thanks.
> --
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
> "Masudur"  wrote in message 
> news:1181974218.719890.57440@o11g2000prd.googlegroups.com...
>> On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:
>>> I have a page which I dynamically add several usercontrols (*.ascx 
>>> files) to
>>> using the following code:
>>>
>>>  Public Sub Refresh()
>>>   For Each section As DataRow In Me.GetSections().Rows
>>>    CType(Me.FindControl("admin" & CStr(section("buttontext")).Replace(" 
>>> ",
>>> "")), adminsection2).RefreshSection()
>>>   Next
>>>  End Sub
>>>
>>>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>> System.EventArgs) Handles Me.Load
>>>   Dim sections As DataTable = Me.GetSections()
>>>   For Each section As DataRow In sections.Rows
>>>    Me.AddAdminSection(CStr(section("buttontext")))
>>>   Next
>>>   Me.Refresh()
>>>  End Sub
>>>
>>>  Private Function GetSections() As DataTable
>>>   Dim sections As New DataTable
>>>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext FROM
>>> subnavigation WHERE buttontext<>'More.' AND category='" &
>>> Request.QueryString("category") & "' ORDER BY buttonorder",
>>> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>>>   dataadapterSelect.Fill(sections)
>>>   Return sections
>>>  End Function
>>>
>>>  Private Sub AddAdminSection(ByVal section As String)
>>>   Dim admin As adminsection2 =
>>> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), 
>>> adminsection2)
>>>   admin.ID = "admin" & section.Replace(" ", "")
>>>   admin.Section = section
>>>   Me.form1.Controls.Add(admin)
>>>  End Sub
>>>
>>> My problem is that the controls are reloaded every time, as you can see 
>>> from
>>> the Load event. If I place the following line
>>>
>>> Me.AddAdminSection(CStr(section("buttontext")))
>>>
>>> in an If Not Me.IsPostBack() statement, then it is only loaded the first
>>> time and I recieve an object does not exist error every time the 
>>> Refresh()
>>> method is called (which is reasonably often, because this is for an
>>> administration page where the user edits DB records). What can I do to
>>> maintain the look of the dynamically added controls (in other words, how 
>>> can
>>> I avoid replacing them with every postback)? If there is any other code 
>>> you
>>> need to see that might help, let me know. Thanks.
>>> --
>>> Nathan Sokalski
>>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>>
>> Hi,
>>
>> Dynamically loaded controls need to be load after each post back...
>> other wise dynamically loaded control's event wont work...
>> Its always a good practice to load the controls in page_init event
>>
>> Thanks
>> Masudur
>>
>
> 
Date:Mon, 18 Jun 2007 06:59:09 +0200   Author:  

Re: Maintaining the look of dynamically added usercontrols   
Nathan,

Probably Ajax,  however I am seriously curious what a usercontrol for ASPNET 
has to do with ADONET.

Cor

"Nathan Sokalski"  schreef in bericht 
news:eTM78JIsHHA.4992@TK2MSFTNGP05.phx.gbl...

> Isn't there any kind of workaround? I am sure that I am not the first 
> person to want to maintain the properties of dynamically loaded 
> usercontrols between postbacks. Anybody have any ideas? Thanks.
> --
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
> "Masudur"  wrote in message 
> news:1181974218.719890.57440@o11g2000prd.googlegroups.com...
>> On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:
>>> I have a page which I dynamically add several usercontrols (*.ascx 
>>> files) to
>>> using the following code:
>>>
>>>  Public Sub Refresh()
>>>   For Each section As DataRow In Me.GetSections().Rows
>>>    CType(Me.FindControl("admin" & CStr(section("buttontext")).Replace(" 
>>> ",
>>> "")), adminsection2).RefreshSection()
>>>   Next
>>>  End Sub
>>>
>>>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>> System.EventArgs) Handles Me.Load
>>>   Dim sections As DataTable = Me.GetSections()
>>>   For Each section As DataRow In sections.Rows
>>>    Me.AddAdminSection(CStr(section("buttontext")))
>>>   Next
>>>   Me.Refresh()
>>>  End Sub
>>>
>>>  Private Function GetSections() As DataTable
>>>   Dim sections As New DataTable
>>>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext FROM
>>> subnavigation WHERE buttontext<>'More.' AND category='" &
>>> Request.QueryString("category") & "' ORDER BY buttonorder",
>>> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>>>   dataadapterSelect.Fill(sections)
>>>   Return sections
>>>  End Function
>>>
>>>  Private Sub AddAdminSection(ByVal section As String)
>>>   Dim admin As adminsection2 =
>>> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), 
>>> adminsection2)
>>>   admin.ID = "admin" & section.Replace(" ", "")
>>>   admin.Section = section
>>>   Me.form1.Controls.Add(admin)
>>>  End Sub
>>>
>>> My problem is that the controls are reloaded every time, as you can see 
>>> from
>>> the Load event. If I place the following line
>>>
>>> Me.AddAdminSection(CStr(section("buttontext")))
>>>
>>> in an If Not Me.IsPostBack() statement, then it is only loaded the first
>>> time and I recieve an object does not exist error every time the 
>>> Refresh()
>>> method is called (which is reasonably often, because this is for an
>>> administration page where the user edits DB records). What can I do to
>>> maintain the look of the dynamically added controls (in other words, how 
>>> can
>>> I avoid replacing them with every postback)? If there is any other code 
>>> you
>>> need to see that might help, let me know. Thanks.
>>> --
>>> Nathan Sokalski
>>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>>
>> Hi,
>>
>> Dynamically loaded controls need to be load after each post back...
>> other wise dynamically loaded control's event wont work...
>> Its always a good practice to load the controls in page_init event
>>
>> Thanks
>> Masudur
>>
>
> 
Date:Mon, 18 Jun 2007 06:59:09 +0200   Author:  

Re: Maintaining the look of dynamically added usercontrols   
"Nathan Sokalski"  wrote in message 
news:eTM78JIsHHA.4992@TK2MSFTNGP05.phx.gbl...

> Isn't there any kind of workaround? I am sure that I am not the first 
> person to want to maintain the properties of dynamically loaded 
> usercontrols between postbacks. Anybody have any ideas? Thanks.


You have to load dynamically added controls each time. Their properties are 
mantained as with static controls.
-- 
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
Date:Mon, 18 Jun 2007 08:39:50 +0200   Author:  

Re: Maintaining the look of dynamically added usercontrols   
"Nathan Sokalski"  wrote in message 
news:eTM78JIsHHA.4992@TK2MSFTNGP05.phx.gbl...

> Isn't there any kind of workaround? I am sure that I am not the first 
> person to want to maintain the properties of dynamically loaded 
> usercontrols between postbacks. Anybody have any ideas? Thanks.


You have to load dynamically added controls each time. Their properties are 
mantained as with static controls.
-- 
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
Date:Mon, 18 Jun 2007 08:39:50 +0200   Author:  

Re: Maintaining the look of dynamically added usercontrols   
"Nathan Sokalski"  wrote in message 
news:eTM78JIsHHA.4992@TK2MSFTNGP05.phx.gbl...

> Isn't there any kind of workaround? I am sure that I am not the first 
> person to want to maintain the properties of dynamically loaded 
> usercontrols between postbacks. Anybody have any ideas? Thanks.


You have to load dynamically added controls each time. Their properties are 
mantained as with static controls.
-- 
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
Date:Mon, 18 Jun 2007 08:39:50 +0200   Author:  

Re: Maintaining the look of dynamically added usercontrols   
The dynamically added usercontrols that I want to maintain the look of 
contain AJAX, and the reason for the postbacks is to update the data 
accessed using ADO.NET, so there are your relations to AJAX and ADO.NET. The 
main tags in the usercontrol are the following:

<asp:Panel>
     <asp:Label/>
</asp:Panel>
<asp:Panel>
     <asp:DataList>
     </asp:DataList>
</asp:Panel>
<AJAX:CollapsiblePanelExtender/>

(obviously the controls all have their properties, and the DataList has it's 
ItemTemplate and EditItemTemplate). The property that I am having trouble 
maintaining is the Collapsed property of the CollapsiblePanelExtender 
control. The postbacks are usually caused by eventbubbling through Button 
controls in the DataList. I haven't tried it yet, but one idea I thought 
about was to put the DataList inside an UpdatePanel. The only concerns I had 
with this idea were:

1. In some cases, a record is moved from the DataSource of one DataList to 
the DataSource of another DataList. This would mean I would still need a way 
to update all the DataLists regardless. Any ideas to make this possibility 
work?

2. There is one section that on the page (not in the usercontrols, but on 
the page that contains the usercontrols) that is used to add records, 
obviously causing a postback. This would cause pretty much the same 
situation as Concern #1, and would probably be solved in a similar way. Any 
ideas for this?

The code I currently use to update the usercontrols is the following. The 
*.ascx.vb file contains the following method, which is called for all of the 
usercontrols from a method in the containing page (I removed the 
OleDbDataAdapter's SQL to keep the code short in the posting):

Public Sub RefreshSection()
 Dim sectiontable As New DataTable
 Dim sectionadapter As New OleDbDataAdapter("", 
ConfigurationManager.AppSettings("connectionstring"))
 sectionadapter.Fill(sectiontable)
 Me.datSection.DataSource = sectiontable
 Me.datSection.DataBind()
End Sub

Do any of these ideas or information help give a way to solve my problem? 
Thanks.
-- 
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

"Cor Ligthert [MVP]"  wrote in message 
news:%239YYxTWsHHA.4500@TK2MSFTNGP04.phx.gbl...

> Nathan,
>
> Probably Ajax,  however I am seriously curious what a usercontrol for 
> ASPNET has to do with ADONET.
>
> Cor
>
> "Nathan Sokalski"  schreef in bericht 
> news:eTM78JIsHHA.4992@TK2MSFTNGP05.phx.gbl...
>> Isn't there any kind of workaround? I am sure that I am not the first 
>> person to want to maintain the properties of dynamically loaded 
>> usercontrols between postbacks. Anybody have any ideas? Thanks.
>> --
>> Nathan Sokalski
>> njsokalski@hotmail.com
>> http://www.nathansokalski.com/
>>
>> "Masudur"  wrote in message 
>> news:1181974218.719890.57440@o11g2000prd.googlegroups.com...
>>> On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:
>>>> I have a page which I dynamically add several usercontrols (*.ascx 
>>>> files) to
>>>> using the following code:
>>>>
>>>>  Public Sub Refresh()
>>>>   For Each section As DataRow In Me.GetSections().Rows
>>>>    CType(Me.FindControl("admin" & CStr(section("buttontext")).Replace(" 
>>>> ",
>>>> "")), adminsection2).RefreshSection()
>>>>   Next
>>>>  End Sub
>>>>
>>>>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>>> System.EventArgs) Handles Me.Load
>>>>   Dim sections As DataTable = Me.GetSections()
>>>>   For Each section As DataRow In sections.Rows
>>>>    Me.AddAdminSection(CStr(section("buttontext")))
>>>>   Next
>>>>   Me.Refresh()
>>>>  End Sub
>>>>
>>>>  Private Function GetSections() As DataTable
>>>>   Dim sections As New DataTable
>>>>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext FROM
>>>> subnavigation WHERE buttontext<>'More.' AND category='" &
>>>> Request.QueryString("category") & "' ORDER BY buttonorder",
>>>> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>>>>   dataadapterSelect.Fill(sections)
>>>>   Return sections
>>>>  End Function
>>>>
>>>>  Private Sub AddAdminSection(ByVal section As String)
>>>>   Dim admin As adminsection2 =
>>>> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), 
>>>> adminsection2)
>>>>   admin.ID = "admin" & section.Replace(" ", "")
>>>>   admin.Section = section
>>>>   Me.form1.Controls.Add(admin)
>>>>  End Sub
>>>>
>>>> My problem is that the controls are reloaded every time, as you can see 
>>>> from
>>>> the Load event. If I place the following line
>>>>
>>>> Me.AddAdminSection(CStr(section("buttontext")))
>>>>
>>>> in an If Not Me.IsPostBack() statement, then it is only loaded the 
>>>> first
>>>> time and I recieve an object does not exist error every time the 
>>>> Refresh()
>>>> method is called (which is reasonably often, because this is for an
>>>> administration page where the user edits DB records). What can I do to
>>>> maintain the look of the dynamically added controls (in other words, 
>>>> how can
>>>> I avoid replacing them with every postback)? If there is any other code 
>>>> you
>>>> need to see that might help, let me know. Thanks.
>>>> --
>>>> Nathan Sokalski
>>>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>>>
>>> Hi,
>>>
>>> Dynamically loaded controls need to be load after each post back...
>>> other wise dynamically loaded control's event wont work...
>>> Its always a good practice to load the controls in page_init event
>>>
>>> Thanks
>>> Masudur
>>>
>>
>>
>
> 
Date:Mon, 18 Jun 2007 17:27:34 -0400   Author:  

Re: Maintaining the look of dynamically added usercontrols   
The dynamically added usercontrols that I want to maintain the look of 
contain AJAX, and the reason for the postbacks is to update the data 
accessed using ADO.NET, so there are your relations to AJAX and ADO.NET. The 
main tags in the usercontrol are the following:

<asp:Panel>
     <asp:Label/>
</asp:Panel>
<asp:Panel>
     <asp:DataList>
     </asp:DataList>
</asp:Panel>
<AJAX:CollapsiblePanelExtender/>

(obviously the controls all have their properties, and the DataList has it's 
ItemTemplate and EditItemTemplate). The property that I am having trouble 
maintaining is the Collapsed property of the CollapsiblePanelExtender 
control. The postbacks are usually caused by eventbubbling through Button 
controls in the DataList. I haven't tried it yet, but one idea I thought 
about was to put the DataList inside an UpdatePanel. The only concerns I had 
with this idea were:

1. In some cases, a record is moved from the DataSource of one DataList to 
the DataSource of another DataList. This would mean I would still need a way 
to update all the DataLists regardless. Any ideas to make this possibility 
work?

2. There is one section that on the page (not in the usercontrols, but on 
the page that contains the usercontrols) that is used to add records, 
obviously causing a postback. This would cause pretty much the same 
situation as Concern #1, and would probably be solved in a similar way. Any 
ideas for this?

The code I currently use to update the usercontrols is the following. The 
*.ascx.vb file contains the following method, which is called for all of the 
usercontrols from a method in the containing page (I removed the 
OleDbDataAdapter's SQL to keep the code short in the posting):

Public Sub RefreshSection()
 Dim sectiontable As New DataTable
 Dim sectionadapter As New OleDbDataAdapter("", 
ConfigurationManager.AppSettings("connectionstring"))
 sectionadapter.Fill(sectiontable)
 Me.datSection.DataSource = sectiontable
 Me.datSection.DataBind()
End Sub

Do any of these ideas or information help give a way to solve my problem? 
Thanks.
-- 
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

"Cor Ligthert [MVP]"  wrote in message 
news:%239YYxTWsHHA.4500@TK2MSFTNGP04.phx.gbl...

> Nathan,
>
> Probably Ajax,  however I am seriously curious what a usercontrol for 
> ASPNET has to do with ADONET.
>
> Cor
>
> "Nathan Sokalski"  schreef in bericht 
> news:eTM78JIsHHA.4992@TK2MSFTNGP05.phx.gbl...
>> Isn't there any kind of workaround? I am sure that I am not the first 
>> person to want to maintain the properties of dynamically loaded 
>> usercontrols between postbacks. Anybody have any ideas? Thanks.
>> --
>> Nathan Sokalski
>> njsokalski@hotmail.com
>> http://www.nathansokalski.com/
>>
>> "Masudur"  wrote in message 
>> news:1181974218.719890.57440@o11g2000prd.googlegroups.com...
>>> On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:
>>>> I have a page which I dynamically add several usercontrols (*.ascx 
>>>> files) to
>>>> using the following code:
>>>>
>>>>  Public Sub Refresh()
>>>>   For Each section As DataRow In Me.GetSections().Rows
>>>>    CType(Me.FindControl("admin" & CStr(section("buttontext")).Replace(" 
>>>> ",
>>>> "")), adminsection2).RefreshSection()
>>>>   Next
>>>>  End Sub
>>>>
>>>>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>>> System.EventArgs) Handles Me.Load
>>>>   Dim sections As DataTable = Me.GetSections()
>>>>   For Each section As DataRow In sections.Rows
>>>>    Me.AddAdminSection(CStr(section("buttontext")))
>>>>   Next
>>>>   Me.Refresh()
>>>>  End Sub
>>>>
>>>>  Private Function GetSections() As DataTable
>>>>   Dim sections As New DataTable
>>>>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext FROM
>>>> subnavigation WHERE buttontext<>'More.' AND category='" &
>>>> Request.QueryString("category") & "' ORDER BY buttonorder",
>>>> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>>>>   dataadapterSelect.Fill(sections)
>>>>   Return sections
>>>>  End Function
>>>>
>>>>  Private Sub AddAdminSection(ByVal section As String)
>>>>   Dim admin As adminsection2 =
>>>> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), 
>>>> adminsection2)
>>>>   admin.ID = "admin" & section.Replace(" ", "")
>>>>   admin.Section = section
>>>>   Me.form1.Controls.Add(admin)
>>>>  End Sub
>>>>
>>>> My problem is that the controls are reloaded every time, as you can see 
>>>> from
>>>> the Load event. If I place the following line
>>>>
>>>> Me.AddAdminSection(CStr(section("buttontext")))
>>>>
>>>> in an If Not Me.IsPostBack() statement, then it is only loaded the 
>>>> first
>>>> time and I recieve an object does not exist error every time the 
>>>> Refresh()
>>>> method is called (which is reasonably often, because this is for an
>>>> administration page where the user edits DB records). What can I do to
>>>> maintain the look of the dynamically added controls (in other words, 
>>>> how can
>>>> I avoid replacing them with every postback)? If there is any other code 
>>>> you
>>>> need to see that might help, let me know. Thanks.
>>>> --
>>>> Nathan Sokalski
>>>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>>>
>>> Hi,
>>>
>>> Dynamically loaded controls need to be load after each post back...
>>> other wise dynamically loaded control's event wont work...
>>> Its always a good practice to load the controls in page_init event
>>>
>>> Thanks
>>> Masudur
>>>
>>
>>
>
> 
Date:Mon, 18 Jun 2007 17:27:34 -0400   Author:  

Re: Maintaining the look of dynamically added usercontrols   
The dynamically added usercontrols that I want to maintain the look of 
contain AJAX, and the reason for the postbacks is to update the data 
accessed using ADO.NET, so there are your relations to AJAX and ADO.NET. The 
main tags in the usercontrol are the following:

<asp:Panel>
     <asp:Label/>
</asp:Panel>
<asp:Panel>
     <asp:DataList>
     </asp:DataList>
</asp:Panel>
<AJAX:CollapsiblePanelExtender/>

(obviously the controls all have their properties, and the DataList has it's 
ItemTemplate and EditItemTemplate). The property that I am having trouble 
maintaining is the Collapsed property of the CollapsiblePanelExtender 
control. The postbacks are usually caused by eventbubbling through Button 
controls in the DataList. I haven't tried it yet, but one idea I thought 
about was to put the DataList inside an UpdatePanel. The only concerns I had 
with this idea were:

1. In some cases, a record is moved from the DataSource of one DataList to 
the DataSource of another DataList. This would mean I would still need a way 
to update all the DataLists regardless. Any ideas to make this possibility 
work?

2. There is one section that on the page (not in the usercontrols, but on 
the page that contains the usercontrols) that is used to add records, 
obviously causing a postback. This would cause pretty much the same 
situation as Concern #1, and would probably be solved in a similar way. Any 
ideas for this?

The code I currently use to update the usercontrols is the following. The 
*.ascx.vb file contains the following method, which is called for all of the 
usercontrols from a method in the containing page (I removed the 
OleDbDataAdapter's SQL to keep the code short in the posting):

Public Sub RefreshSection()
 Dim sectiontable As New DataTable
 Dim sectionadapter As New OleDbDataAdapter("", 
ConfigurationManager.AppSettings("connectionstring"))
 sectionadapter.Fill(sectiontable)
 Me.datSection.DataSource = sectiontable
 Me.datSection.DataBind()
End Sub

Do any of these ideas or information help give a way to solve my problem? 
Thanks.
-- 
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

"Cor Ligthert [MVP]"  wrote in message 
news:%239YYxTWsHHA.4500@TK2MSFTNGP04.phx.gbl...

> Nathan,
>
> Probably Ajax,  however I am seriously curious what a usercontrol for 
> ASPNET has to do with ADONET.
>
> Cor
>
> "Nathan Sokalski"  schreef in bericht 
> news:eTM78JIsHHA.4992@TK2MSFTNGP05.phx.gbl...
>> Isn't there any kind of workaround? I am sure that I am not the first 
>> person to want to maintain the properties of dynamically loaded 
>> usercontrols between postbacks. Anybody have any ideas? Thanks.
>> --
>> Nathan Sokalski
>> njsokalski@hotmail.com
>> http://www.nathansokalski.com/
>>
>> "Masudur"  wrote in message 
>> news:1181974218.719890.57440@o11g2000prd.googlegroups.com...
>>> On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:
>>>> I have a page which I dynamically add several usercontrols (*.ascx 
>>>> files) to
>>>> using the following code:
>>>>
>>>>  Public Sub Refresh()
>>>>   For Each section As DataRow In Me.GetSections().Rows
>>>>    CType(Me.FindControl("admin" & CStr(section("buttontext")).Replace(" 
>>>> ",
>>>> "")), adminsection2).RefreshSection()
>>>>   Next
>>>>  End Sub
>>>>
>>>>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>>> System.EventArgs) Handles Me.Load
>>>>   Dim sections As DataTable = Me.GetSections()
>>>>   For Each section As DataRow In sections.Rows
>>>>    Me.AddAdminSection(CStr(section("buttontext")))
>>>>   Next
>>>>   Me.Refresh()
>>>>  End Sub
>>>>
>>>>  Private Function GetSections() As DataTable
>>>>   Dim sections As New DataTable
>>>>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext FROM
>>>> subnavigation WHERE buttontext<>'More.' AND category='" &
>>>> Request.QueryString("category") & "' ORDER BY buttonorder",
>>>> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>>>>   dataadapterSelect.Fill(sections)
>>>>   Return sections
>>>>  End Function
>>>>
>>>>  Private Sub AddAdminSection(ByVal section As String)
>>>>   Dim admin As adminsection2 =
>>>> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), 
>>>> adminsection2)
>>>>   admin.ID = "admin" & section.Replace(" ", "")
>>>>   admin.Section = section
>>>>   Me.form1.Controls.Add(admin)
>>>>  End Sub
>>>>
>>>> My problem is that the controls are reloaded every time, as you can see 
>>>> from
>>>> the Load event. If I place the following line
>>>>
>>>> Me.AddAdminSection(CStr(section("buttontext")))
>>>>
>>>> in an If Not Me.IsPostBack() statement, then it is only loaded the 
>>>> first
>>>> time and I recieve an object does not exist error every time the 
>>>> Refresh()
>>>> method is called (which is reasonably often, because this is for an
>>>> administration page where the user edits DB records). What can I do to
>>>> maintain the look of the dynamically added controls (in other words, 
>>>> how can
>>>> I avoid replacing them with every postback)? If there is any other code 
>>>> you
>>>> need to see that might help, let me know. Thanks.
>>>> --
>>>> Nathan Sokalski
>>>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>>>
>>> Hi,
>>>
>>> Dynamically loaded controls need to be load after each post back...
>>> other wise dynamically loaded control's event wont work...
>>> Its always a good practice to load the controls in page_init event
>>>
>>> Thanks
>>> Masudur
>>>
>>
>>
>
> 
Date:Mon, 18 Jun 2007 17:27:34 -0400   Author:  

Re: Maintaining the look of dynamically added usercontrols   
Nathan,

We have used that on our VB-Tips website, however I have not enough time to 
get a nice sample from that.  Why don't you make for your self a simple 
sample only containing your problem.

You will find that you than find the solution.

Cor

"Nathan Sokalski"  schreef in bericht 
news:%23l3H49esHHA.4572@TK2MSFTNGP02.phx.gbl...

> The dynamically added usercontrols that I want to maintain the look of 
> contain AJAX, and the reason for the postbacks is to update the data 
> accessed using ADO.NET, so there are your relations to AJAX and ADO.NET. 
> The main tags in the usercontrol are the following:
>
> <asp:Panel>
>     <asp:Label/>
> </asp:Panel>
> <asp:Panel>
>     <asp:DataList>
>     </asp:DataList>
> </asp:Panel>
> <AJAX:CollapsiblePanelExtender/>
>
> (obviously the controls all have their properties, and the DataList has 
> it's ItemTemplate and EditItemTemplate). The property that I am having 
> trouble maintaining is the Collapsed property of the 
> CollapsiblePanelExtender control. The postbacks are usually caused by 
> eventbubbling through Button controls in the DataList. I haven't tried it 
> yet, but one idea I thought about was to put the DataList inside an 
> UpdatePanel. The only concerns I had with this idea were:
>
> 1. In some cases, a record is moved from the DataSource of one DataList to 
> the DataSource of another DataList. This would mean I would still need a 
> way to update all the DataLists regardless. Any ideas to make this 
> possibility work?
>
> 2. There is one section that on the page (not in the usercontrols, but on 
> the page that contains the usercontrols) that is used to add records, 
> obviously causing a postback. This would cause pretty much the same 
> situation as Concern #1, and would probably be solved in a similar way. 
> Any ideas for this?
>
> The code I currently use to update the usercontrols is the following. The 
> *.ascx.vb file contains the following method, which is called for all of 
> the usercontrols from a method in the containing page (I removed the 
> OleDbDataAdapter's SQL to keep the code short in the posting):
>
> Public Sub RefreshSection()
> Dim sectiontable As New DataTable
> Dim sectionadapter As New OleDbDataAdapter("", 
> ConfigurationManager.AppSettings("connectionstring"))
> sectionadapter.Fill(sectiontable)
> Me.datSection.DataSource = sectiontable
> Me.datSection.DataBind()
> End Sub
>
> Do any of these ideas or information help give a way to solve my problem? 
> Thanks.
> -- 
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
> "Cor Ligthert [MVP]"  wrote in message 
> news:%239YYxTWsHHA.4500@TK2MSFTNGP04.phx.gbl...
>> Nathan,
>>
>> Probably Ajax,  however I am seriously curious what a usercontrol for 
>> ASPNET has to do with ADONET.
>>
>> Cor
>>
>> "Nathan Sokalski"  schreef in bericht 
>> news:eTM78JIsHHA.4992@TK2MSFTNGP05.phx.gbl...
>>> Isn't there any kind of workaround? I am sure that I am not the first 
>>> person to want to maintain the properties of dynamically loaded 
>>> usercontrols between postbacks. Anybody have any ideas? Thanks.
>>> --
>>> Nathan Sokalski
>>> njsokalski@hotmail.com
>>> http://www.nathansokalski.com/
>>>
>>> "Masudur"  wrote in message 
>>> news:1181974218.719890.57440@o11g2000prd.googlegroups.com...
>>>> On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:
>>>>> I have a page which I dynamically add several usercontrols (*.ascx 
>>>>> files) to
>>>>> using the following code:
>>>>>
>>>>>  Public Sub Refresh()
>>>>>   For Each section As DataRow In Me.GetSections().Rows
>>>>>    CType(Me.FindControl("admin" & 
>>>>> CStr(section("buttontext")).Replace(" ",
>>>>> "")), adminsection2).RefreshSection()
>>>>>   Next
>>>>>  End Sub
>>>>>
>>>>>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>>>> System.EventArgs) Handles Me.Load
>>>>>   Dim sections As DataTable = Me.GetSections()
>>>>>   For Each section As DataRow In sections.Rows
>>>>>    Me.AddAdminSection(CStr(section("buttontext")))
>>>>>   Next
>>>>>   Me.Refresh()
>>>>>  End Sub
>>>>>
>>>>>  Private Function GetSections() As DataTable
>>>>>   Dim sections As New DataTable
>>>>>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext 
>>>>> FROM
>>>>> subnavigation WHERE buttontext<>'More.' AND category='" &
>>>>> Request.QueryString("category") & "' ORDER BY buttonorder",
>>>>> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>>>>>   dataadapterSelect.Fill(sections)
>>>>>   Return sections
>>>>>  End Function
>>>>>
>>>>>  Private Sub AddAdminSection(ByVal section As String)
>>>>>   Dim admin As adminsection2 =
>>>>> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), 
>>>>> adminsection2)
>>>>>   admin.ID = "admin" & section.Replace(" ", "")
>>>>>   admin.Section = section
>>>>>   Me.form1.Controls.Add(admin)
>>>>>  End Sub
>>>>>
>>>>> My problem is that the controls are reloaded every time, as you can 
>>>>> see from
>>>>> the Load event. If I place the following line
>>>>>
>>>>> Me.AddAdminSection(CStr(section("buttontext")))
>>>>>
>>>>> in an If Not Me.IsPostBack() statement, then it is only loaded the 
>>>>> first
>>>>> time and I recieve an object does not exist error every time the 
>>>>> Refresh()
>>>>> method is called (which is reasonably often, because this is for an
>>>>> administration page where the user edits DB records). What can I do to
>>>>> maintain the look of the dynamically added controls (in other words, 
>>>>> how can
>>>>> I avoid replacing them with every postback)? If there is any other 
>>>>> code you
>>>>> need to see that might help, let me know. Thanks.
>>>>> --
>>>>> Nathan Sokalski
>>>>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>>>>
>>>> Hi,
>>>>
>>>> Dynamically loaded controls need to be load after each post back...
>>>> other wise dynamically loaded control's event wont work...
>>>> Its always a good practice to load the controls in page_init event
>>>>
>>>> Thanks
>>>> Masudur
>>>>
>>>
>>>
>>
>>
>
> 
Date:Tue, 19 Jun 2007 07:03:51 +0200   Author:  

Re: Maintaining the look of dynamically added usercontrols   
If it was now friday I could make the sample.


"Nathan Sokalski"  schreef in bericht 
news:%23l3H49esHHA.4572@TK2MSFTNGP02.phx.gbl...

> The dynamically added usercontrols that I want to maintain the look of 
> contain AJAX, and the reason for the postbacks is to update the data 
> accessed using ADO.NET, so there are your relations to AJAX and ADO.NET. 
> The main tags in the usercontrol are the following:
>
> <asp:Panel>
>     <asp:Label/>
> </asp:Panel>
> <asp:Panel>
>     <asp:DataList>
>     </asp:DataList>
> </asp:Panel>
> <AJAX:CollapsiblePanelExtender/>
>
> (obviously the controls all have their properties, and the DataList has 
> it's ItemTemplate and EditItemTemplate). The property that I am having 
> trouble maintaining is the Collapsed property of the 
> CollapsiblePanelExtender control. The postbacks are usually caused by 
> eventbubbling through Button controls in the DataList. I haven't tried it 
> yet, but one idea I thought about was to put the DataList inside an 
> UpdatePanel. The only concerns I had with this idea were:
>
> 1. In some cases, a record is moved from the DataSource of one DataList to 
> the DataSource of another DataList. This would mean I would still need a 
> way to update all the DataLists regardless. Any ideas to make this 
> possibility work?
>
> 2. There is one section that on the page (not in the usercontrols, but on 
> the page that contains the usercontrols) that is used to add records, 
> obviously causing a postback. This would cause pretty much the same 
> situation as Concern #1, and would probably be solved in a similar way. 
> Any ideas for this?
>
> The code I currently use to update the usercontrols is the following. The 
> *.ascx.vb file contains the following method, which is called for all of 
> the usercontrols from a method in the containing page (I removed the 
> OleDbDataAdapter's SQL to keep the code short in the posting):
>
> Public Sub RefreshSection()
> Dim sectiontable As New DataTable
> Dim sectionadapter As New OleDbDataAdapter("", 
> ConfigurationManager.AppSettings("connectionstring"))
> sectionadapter.Fill(sectiontable)
> Me.datSection.DataSource = sectiontable
> Me.datSection.DataBind()
> End Sub
>
> Do any of these ideas or information help give a way to solve my problem? 
> Thanks.
> -- 
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
> "Cor Ligthert [MVP]"  wrote in message 
> news:%239YYxTWsHHA.4500@TK2MSFTNGP04.phx.gbl...
>> Nathan,
>>
>> Probably Ajax,  however I am seriously curious what a usercontrol for 
>> ASPNET has to do with ADONET.
>>
>> Cor
>>
>> "Nathan Sokalski"  schreef in bericht 
>> news:eTM78JIsHHA.4992@TK2MSFTNGP05.phx.gbl...
>>> Isn't there any kind of workaround? I am sure that I am not the first 
>>> person to want to maintain the properties of dynamically loaded 
>>> usercontrols between postbacks. Anybody have any ideas? Thanks.
>>> --
>>> Nathan Sokalski
>>> njsokalski@hotmail.com
>>> http://www.nathansokalski.com/
>>>
>>> "Masudur"  wrote in message 
>>> news:1181974218.719890.57440@o11g2000prd.googlegroups.com...
>>>> On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:
>>>>> I have a page which I dynamically add several usercontrols (*.ascx 
>>>>> files) to
>>>>> using the following code:
>>>>>
>>>>>  Public Sub Refresh()
>>>>>   For Each section As DataRow In Me.GetSections().Rows
>>>>>    CType(Me.FindControl("admin" & 
>>>>> CStr(section("buttontext")).Replace(" ",
>>>>> "")), adminsection2).RefreshSection()
>>>>>   Next
>>>>>  End Sub
>>>>>
>>>>>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>>>> System.EventArgs) Handles Me.Load
>>>>>   Dim sections As DataTable = Me.GetSections()
>>>>>   For Each section As DataRow In sections.Rows
>>>>>    Me.AddAdminSection(CStr(section("buttontext")))
>>>>>   Next
>>>>>   Me.Refresh()
>>>>>  End Sub
>>>>>
>>>>>  Private Function GetSections() As DataTable
>>>>>   Dim sections As New DataTable
>>>>>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext 
>>>>> FROM
>>>>> subnavigation WHERE buttontext<>'More.' AND category='" &
>>>>> Request.QueryString("category") & "' ORDER BY buttonorder",
>>>>> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>>>>>   dataadapterSelect.Fill(sections)
>>>>>   Return sections
>>>>>  End Function
>>>>>
>>>>>  Private Sub AddAdminSection(ByVal section As String)
>>>>>   Dim admin As adminsection2 =
>>>>> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), 
>>>>> adminsection2)
>>>>>   admin.ID = "admin" & section.Replace(" ", "")
>>>>>   admin.Section = section
>>>>>   Me.form1.Controls.Add(admin)
>>>>>  End Sub
>>>>>
>>>>> My problem is that the controls are reloaded every time, as you can 
>>>>> see from
>>>>> the Load event. If I place the following line
>>>>>
>>>>> Me.AddAdminSection(CStr(section("buttontext")))
>>>>>
>>>>> in an If Not Me.IsPostBack() statement, then it is only loaded the 
>>>>> first
>>>>> time and I recieve an object does not exist error every time the 
>>>>> Refresh()
>>>>> method is called (which is reasonably often, because this is for an
>>>>> administration page where the user edits DB records). What can I do to
>>>>> maintain the look of the dynamically added controls (in other words, 
>>>>> how can
>>>>> I avoid replacing them with every postback)? If there is any other 
>>>>> code you
>>>>> need to see that might help, let me know. Thanks.
>>>>> --
>>>>> Nathan Sokalski
>>>>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>>>>
>>>> Hi,
>>>>
>>>> Dynamically loaded controls need to be load after each post back...
>>>> other wise dynamically loaded control's event wont work...
>>>> Its always a good practice to load the controls in page_init event
>>>>
>>>> Thanks
>>>> Masudur
>>>>
>>>
>>>
>>
>>
>
> 
Date:Tue, 19 Jun 2007 07:04:28 +0200   Author:  

Re: Maintaining the look of dynamically added usercontrols   
Nathan,

We have used that on our VB-Tips website, however I have not enough time to 
get a nice sample from that.  Why don't you make for your self a simple 
sample only containing your problem.

You will find that you than find the solution.

Cor

"Nathan Sokalski"  schreef in bericht 
news:%23l3H49esHHA.4572@TK2MSFTNGP02.phx.gbl...

> The dynamically added usercontrols that I want to maintain the look of 
> contain AJAX, and the reason for the postbacks is to update the data 
> accessed using ADO.NET, so there are your relations to AJAX and ADO.NET. 
> The main tags in the usercontrol are the following:
>
> <asp:Panel>
>     <asp:Label/>
> </asp:Panel>
> <asp:Panel>
>     <asp:DataList>
>     </asp:DataList>
> </asp:Panel>
> <AJAX:CollapsiblePanelExtender/>
>
> (obviously the controls all have their properties, and the DataList has 
> it's ItemTemplate and EditItemTemplate). The property that I am having 
> trouble maintaining is the Collapsed property of the 
> CollapsiblePanelExtender control. The postbacks are usually caused by 
> eventbubbling through Button controls in the DataList. I haven't tried it 
> yet, but one idea I thought about was to put the DataList inside an 
> UpdatePanel. The only concerns I had with this idea were:
>
> 1. In some cases, a record is moved from the DataSource of one DataList to 
> the DataSource of another DataList. This would mean I would still need a 
> way to update all the DataLists regardless. Any ideas to make this 
> possibility work?
>
> 2. There is one section that on the page (not in the usercontrols, but on 
> the page that contains the usercontrols) that is used to add records, 
> obviously causing a postback. This would cause pretty much the same 
> situation as Concern #1, and would probably be solved in a similar way. 
> Any ideas for this?
>
> The code I currently use to update the usercontrols is the following. The 
> *.ascx.vb file contains the following method, which is called for all of 
> the usercontrols from a method in the containing page (I removed the 
> OleDbDataAdapter's SQL to keep the code short in the posting):
>
> Public Sub RefreshSection()
> Dim sectiontable As New DataTable
> Dim sectionadapter As New OleDbDataAdapter("", 
> ConfigurationManager.AppSettings("connectionstring"))
> sectionadapter.Fill(sectiontable)
> Me.datSection.DataSource = sectiontable
> Me.datSection.DataBind()
> End Sub
>
> Do any of these ideas or information help give a way to solve my problem? 
> Thanks.
> -- 
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
> "Cor Ligthert [MVP]"  wrote in message 
> news:%239YYxTWsHHA.4500@TK2MSFTNGP04.phx.gbl...
>> Nathan,
>>
>> Probably Ajax,  however I am seriously curious what a usercontrol for 
>> ASPNET has to do with ADONET.
>>
>> Cor
>>
>> "Nathan Sokalski"  schreef in bericht 
>> news:eTM78JIsHHA.4992@TK2MSFTNGP05.phx.gbl...
>>> Isn't there any kind of workaround? I am sure that I am not the first 
>>> person to want to maintain the properties of dynamically loaded 
>>> usercontrols between postbacks. Anybody have any ideas? Thanks.
>>> --
>>> Nathan Sokalski
>>> njsokalski@hotmail.com
>>> http://www.nathansokalski.com/
>>>
>>> "Masudur"  wrote in message 
>>> news:1181974218.719890.57440@o11g2000prd.googlegroups.com...
>>>> On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:
>>>>> I have a page which I dynamically add several usercontrols (*.ascx 
>>>>> files) to
>>>>> using the following code:
>>>>>
>>>>>  Public Sub Refresh()
>>>>>   For Each section As DataRow In Me.GetSections().Rows
>>>>>    CType(Me.FindControl("admin" & 
>>>>> CStr(section("buttontext")).Replace(" ",
>>>>> "")), adminsection2).RefreshSection()
>>>>>   Next
>>>>>  End Sub
>>>>>
>>>>>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>>>> System.EventArgs) Handles Me.Load
>>>>>   Dim sections As DataTable = Me.GetSections()
>>>>>   For Each section As DataRow In sections.Rows
>>>>>    Me.AddAdminSection(CStr(section("buttontext")))
>>>>>   Next
>>>>>   Me.Refresh()
>>>>>  End Sub
>>>>>
>>>>>  Private Function GetSections() As DataTable
>>>>>   Dim sections As New DataTable
>>>>>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext 
>>>>> FROM
>>>>> subnavigation WHERE buttontext<>'More.' AND category='" &
>>>>> Request.QueryString("category") & "' ORDER BY buttonorder",
>>>>> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>>>>>   dataadapterSelect.Fill(sections)
>>>>>   Return sections
>>>>>  End Function
>>>>>
>>>>>  Private Sub AddAdminSection(ByVal section As String)
>>>>>   Dim admin As adminsection2 =
>>>>> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), 
>>>>> adminsection2)
>>>>>   admin.ID = "admin" & section.Replace(" ", "")
>>>>>   admin.Section = section
>>>>>   Me.form1.Controls.Add(admin)
>>>>>  End Sub
>>>>>
>>>>> My problem is that the controls are reloaded every time, as you can 
>>>>> see from
>>>>> the Load event. If I place the following line
>>>>>
>>>>> Me.AddAdminSection(CStr(section("buttontext")))
>>>>>
>>>>> in an If Not Me.IsPostBack() statement, then it is only loaded the 
>>>>> first
>>>>> time and I recieve an object does not exist error every time the 
>>>>> Refresh()
>>>>> method is called (which is reasonably often, because this is for an
>>>>> administration page where the user edits DB records). What can I do to
>>>>> maintain the look of the dynamically added controls (in other words, 
>>>>> how can
>>>>> I avoid replacing them with every postback)? If there is any other 
>>>>> code you
>>>>> need to see that might help, let me know. Thanks.
>>>>> --
>>>>> Nathan Sokalski
>>>>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>>>>
>>>> Hi,
>>>>
>>>> Dynamically loaded controls need to be load after each post back...
>>>> other wise dynamically loaded control's event wont work...
>>>> Its always a good practice to load the controls in page_init event
>>>>
>>>> Thanks
>>>> Masudur
>>>>
>>>
>>>
>>
>>
>
> 
Date:Tue, 19 Jun 2007 07:03:51 +0200   Author:  

Re: Maintaining the look of dynamically added usercontrols   
If it was now friday I could make the sample.


"Nathan Sokalski"  schreef in bericht 
news:%23l3H49esHHA.4572@TK2MSFTNGP02.phx.gbl...

> The dynamically added usercontrols that I want to maintain the look of 
> contain AJAX, and the reason for the postbacks is to update the data 
> accessed using ADO.NET, so there are your relations to AJAX and ADO.NET. 
> The main tags in the usercontrol are the following:
>
> <asp:Panel>
>     <asp:Label/>
> </asp:Panel>
> <asp:Panel>
>     <asp:DataList>
>     </asp:DataList>
> </asp:Panel>
> <AJAX:CollapsiblePanelExtender/>
>
> (obviously the controls all have their properties, and the DataList has 
> it's ItemTemplate and EditItemTemplate). The property that I am having 
> trouble maintaining is the Collapsed property of the 
> CollapsiblePanelExtender control. The postbacks are usually caused by 
> eventbubbling through Button controls in the DataList. I haven't tried it 
> yet, but one idea I thought about was to put the DataList inside an 
> UpdatePanel. The only concerns I had with this idea were:
>
> 1. In some cases, a record is moved from the DataSource of one DataList to 
> the DataSource of another DataList. This would mean I would still need a 
> way to update all the DataLists regardless. Any ideas to make this 
> possibility work?
>
> 2. There is one section that on the page (not in the usercontrols, but on 
> the page that contains the usercontrols) that is used to add records, 
> obviously causing a postback. This would cause pretty much the same 
> situation as Concern #1, and would probably be solved in a similar way. 
> Any ideas for this?
>
> The code I currently use to update the usercontrols is the following. The 
> *.ascx.vb file contains the following method, which is called for all of 
> the usercontrols from a method in the containing page (I removed the 
> OleDbDataAdapter's SQL to keep the code short in the posting):
>
> Public Sub RefreshSection()
> Dim sectiontable As New DataTable
> Dim sectionadapter As New OleDbDataAdapter("", 
> ConfigurationManager.AppSettings("connectionstring"))
> sectionadapter.Fill(sectiontable)
> Me.datSection.DataSource = sectiontable
> Me.datSection.DataBind()
> End Sub
>
> Do any of these ideas or information help give a way to solve my problem? 
> Thanks.
> -- 
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
> "Cor Ligthert [MVP]"  wrote in message 
> news:%239YYxTWsHHA.4500@TK2MSFTNGP04.phx.gbl...
>> Nathan,
>>
>> Probably Ajax,  however I am seriously curious what a usercontrol for 
>> ASPNET has to do with ADONET.
>>
>> Cor
>>
>> "Nathan Sokalski"  schreef in bericht 
>> news:eTM78JIsHHA.4992@TK2MSFTNGP05.phx.gbl...
>>> Isn't there any kind of workaround? I am sure that I am not the first 
>>> person to want to maintain the properties of dynamically loaded 
>>> usercontrols between postbacks. Anybody have any ideas? Thanks.
>>> --
>>> Nathan Sokalski
>>> njsokalski@hotmail.com
>>> http://www.nathansokalski.com/
>>>
>>> "Masudur"  wrote in message 
>>> news:1181974218.719890.57440@o11g2000prd.googlegroups.com...
>>>> On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:
>>>>> I have a page which I dynamically add several usercontrols (*.ascx 
>>>>> files) to
>>>>> using the following code:
>>>>>
>>>>>  Public Sub Refresh()
>>>>>   For Each section As DataRow In Me.GetSections().Rows
>>>>>    CType(Me.FindControl("admin" & 
>>>>> CStr(section("buttontext")).Replace(" ",
>>>>> "")), adminsection2).RefreshSection()
>>>>>   Next
>>>>>  End Sub
>>>>>
>>>>>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>>>> System.EventArgs) Handles Me.Load
>>>>>   Dim sections As DataTable = Me.GetSections()
>>>>>   For Each section As DataRow In sections.Rows
>>>>>    Me.AddAdminSection(CStr(section("buttontext")))
>>>>>   Next
>>>>>   Me.Refresh()
>>>>>  End Sub
>>>>>
>>>>>  Private Function GetSections() As DataTable
>>>>>   Dim sections As New DataTable
>>>>>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext 
>>>>> FROM
>>>>> subnavigation WHERE buttontext<>'More.' AND category='" &
>>>>> Request.QueryString("category") & "' ORDER BY buttonorder",
>>>>> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>>>>>   dataadapterSelect.Fill(sections)
>>>>>   Return sections
>>>>>  End Function
>>>>>
>>>>>  Private Sub AddAdminSection(ByVal section As String)
>>>>>   Dim admin As adminsection2 =
>>>>> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), 
>>>>> adminsection2)
>>>>>   admin.ID = "admin" & section.Replace(" ", "")
>>>>>   admin.Section = section
>>>>>   Me.form1.Controls.Add(admin)
>>>>>  End Sub
>>>>>
>>>>> My problem is that the controls are reloaded every time, as you can 
>>>>> see from
>>>>> the Load event. If I place the following line
>>>>>
>>>>> Me.AddAdminSection(CStr(section("buttontext")))
>>>>>
>>>>> in an If Not Me.IsPostBack() statement, then it is only loaded the 
>>>>> first
>>>>> time and I recieve an object does not exist error every time the 
>>>>> Refresh()
>>>>> method is called (which is reasonably often, because this is for an
>>>>> administration page where the user edits DB records). What can I do to
>>>>> maintain the look of the dynamically added controls (in other words, 
>>>>> how can
>>>>> I avoid replacing them with every postback)? If there is any other 
>>>>> code you
>>>>> need to see that might help, let me know. Thanks.
>>>>> --
>>>>> Nathan Sokalski
>>>>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>>>>
>>>> Hi,
>>>>
>>>> Dynamically loaded controls need to be load after each post back...
>>>> other wise dynamically loaded control's event wont work...
>>>> Its always a good practice to load the controls in page_init event
>>>>
>>>> Thanks
>>>> Masudur
>>>>
>>>
>>>
>>
>>
>
> 
Date:Tue, 19 Jun 2007 07:04:28 +0200   Author:  

Re: Maintaining the look of dynamically added usercontrols   
Nathan,

We have used that on our VB-Tips website, however I have not enough time to 
get a nice sample from that.  Why don't you make for your self a simple 
sample only containing your problem.

You will find that you than find the solution.

Cor

"Nathan Sokalski"  schreef in bericht 
news:%23l3H49esHHA.4572@TK2MSFTNGP02.phx.gbl...

> The dynamically added usercontrols that I want to maintain the look of 
> contain AJAX, and the reason for the postbacks is to update the data 
> accessed using ADO.NET, so there are your relations to AJAX and ADO.NET. 
> The main tags in the usercontrol are the following:
>
> <asp:Panel>
>     <asp:Label/>
> </asp:Panel>
> <asp:Panel>
>     <asp:DataList>
>     </asp:DataList>
> </asp:Panel>
> <AJAX:CollapsiblePanelExtender/>
>
> (obviously the controls all have their properties, and the DataList has 
> it's ItemTemplate and EditItemTemplate). The property that I am having 
> trouble maintaining is the Collapsed property of the 
> CollapsiblePanelExtender control. The postbacks are usually caused by 
> eventbubbling through Button controls in the DataList. I haven't tried it 
> yet, but one idea I thought about was to put the DataList inside an 
> UpdatePanel. The only concerns I had with this idea were:
>
> 1. In some cases, a record is moved from the DataSource of one DataList to 
> the DataSource of another DataList. This would mean I would still need a 
> way to update all the DataLists regardless. Any ideas to make this 
> possibility work?
>
> 2. There is one section that on the page (not in the usercontrols, but on 
> the page that contains the usercontrols) that is used to add records, 
> obviously causing a postback. This would cause pretty much the same 
> situation as Concern #1, and would probably be solved in a similar way. 
> Any ideas for this?
>
> The code I currently use to update the usercontrols is the following. The 
> *.ascx.vb file contains the following method, which is called for all of 
> the usercontrols from a method in the containing page (I removed the 
> OleDbDataAdapter's SQL to keep the code short in the posting):
>
> Public Sub RefreshSection()
> Dim sectiontable As New DataTable
> Dim sectionadapter As New OleDbDataAdapter("", 
> ConfigurationManager.AppSettings("connectionstring"))
> sectionadapter.Fill(sectiontable)
> Me.datSection.DataSource = sectiontable
> Me.datSection.DataBind()
> End Sub
>
> Do any of these ideas or information help give a way to solve my problem? 
> Thanks.
> -- 
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
> "Cor Ligthert [MVP]"  wrote in message 
> news:%239YYxTWsHHA.4500@TK2MSFTNGP04.phx.gbl...
>> Nathan,
>>
>> Probably Ajax,  however I am seriously curious what a usercontrol for 
>> ASPNET has to do with ADONET.
>>
>> Cor
>>
>> "Nathan Sokalski"  schreef in bericht 
>> news:eTM78JIsHHA.4992@TK2MSFTNGP05.phx.gbl...
>>> Isn't there any kind of workaround? I am sure that I am not the first 
>>> person to want to maintain the properties of dynamically loaded 
>>> usercontrols between postbacks. Anybody have any ideas? Thanks.
>>> --
>>> Nathan Sokalski
>>> njsokalski@hotmail.com
>>> http://www.nathansokalski.com/
>>>
>>> "Masudur"  wrote in message 
>>> news:1181974218.719890.57440@o11g2000prd.googlegroups.com...
>>>> On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:
>>>>> I have a page which I dynamically add several usercontrols (*.ascx 
>>>>> files) to
>>>>> using the following code:
>>>>>
>>>>>  Public Sub Refresh()
>>>>>   For Each section As DataRow In Me.GetSections().Rows
>>>>>    CType(Me.FindControl("admin" & 
>>>>> CStr(section("buttontext")).Replace(" ",
>>>>> "")), adminsection2).RefreshSection()
>>>>>   Next
>>>>>  End Sub
>>>>>
>>>>>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>>>> System.EventArgs) Handles Me.Load
>>>>>   Dim sections As DataTable = Me.GetSections()
>>>>>   For Each section As DataRow In sections.Rows
>>>>>    Me.AddAdminSection(CStr(section("buttontext")))
>>>>>   Next
>>>>>   Me.Refresh()
>>>>>  End Sub
>>>>>
>>>>>  Private Function GetSections() As DataTable
>>>>>   Dim sections As New DataTable
>>>>>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext 
>>>>> FROM
>>>>> subnavigation WHERE buttontext<>'More.' AND category='" &
>>>>> Request.QueryString("category") & "' ORDER BY buttonorder",
>>>>> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>>>>>   dataadapterSelect.Fill(sections)
>>>>>   Return sections
>>>>>  End Function
>>>>>
>>>>>  Private Sub AddAdminSection(ByVal section As String)
>>>>>   Dim admin As adminsection2 =
>>>>> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), 
>>>>> adminsection2)
>>>>>   admin.ID = "admin" & section.Replace(" ", "")
>>>>>   admin.Section = section
>>>>>   Me.form1.Controls.Add(admin)
>>>>>  End Sub
>>>>>
>>>>> My problem is that the controls are reloaded every time, as you can 
>>>>> see from
>>>>> the Load event. If I place the following line
>>>>>
>>>>> Me.AddAdminSection(CStr(section("buttontext")))
>>>>>
>>>>> in an If Not Me.IsPostBack() statement, then it is only loaded the 
>>>>> first
>>>>> time and I recieve an object does not exist error every time the 
>>>>> Refresh()
>>>>> method is called (which is reasonably often, because this is for an
>>>>> administration page where the user edits DB records). What can I do to
>>>>> maintain the look of the dynamically added controls (in other words, 
>>>>> how can
>>>>> I avoid replacing them with every postback)? If there is any other 
>>>>> code you
>>>>> need to see that might help, let me know. Thanks.
>>>>> --
>>>>> Nathan Sokalski
>>>>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>>>>
>>>> Hi,
>>>>
>>>> Dynamically loaded controls need to be load after each post back...
>>>> other wise dynamically loaded control's event wont work...
>>>> Its always a good practice to load the controls in page_init event
>>>>
>>>> Thanks
>>>> Masudur
>>>>
>>>
>>>
>>
>>
>
> 
Date:Tue, 19 Jun 2007 07:03:51 +0200   Author:  

Re: Maintaining the look of dynamically added usercontrols   
If it was now friday I could make the sample.


"Nathan Sokalski"  schreef in bericht 
news:%23l3H49esHHA.4572@TK2MSFTNGP02.phx.gbl...

> The dynamically added usercontrols that I want to maintain the look of 
> contain AJAX, and the reason for the postbacks is to update the data 
> accessed using ADO.NET, so there are your relations to AJAX and ADO.NET. 
> The main tags in the usercontrol are the following:
>
> <asp:Panel>
>     <asp:Label/>
> </asp:Panel>
> <asp:Panel>
>     <asp:DataList>
>     </asp:DataList>
> </asp:Panel>
> <AJAX:CollapsiblePanelExtender/>
>
> (obviously the controls all have their properties, and the DataList has 
> it's ItemTemplate and EditItemTemplate). The property that I am having 
> trouble maintaining is the Collapsed property of the 
> CollapsiblePanelExtender control. The postbacks are usually caused by 
> eventbubbling through Button controls in the DataList. I haven't tried it 
> yet, but one idea I thought about was to put the DataList inside an 
> UpdatePanel. The only concerns I had with this idea were:
>
> 1. In some cases, a record is moved from the DataSource of one DataList to 
> the DataSource of another DataList. This would mean I would still need a 
> way to update all the DataLists regardless. Any ideas to make this 
> possibility work?
>
> 2. There is one section that on the page (not in the usercontrols, but on 
> the page that contains the usercontrols) that is used to add records, 
> obviously causing a postback. This would cause pretty much the same 
> situation as Concern #1, and would probably be solved in a similar way. 
> Any ideas for this?
>
> The code I currently use to update the usercontrols is the following. The 
> *.ascx.vb file contains the following method, which is called for all of 
> the usercontrols from a method in the containing page (I removed the 
> OleDbDataAdapter's SQL to keep the code short in the posting):
>
> Public Sub RefreshSection()
> Dim sectiontable As New DataTable
> Dim sectionadapter As New OleDbDataAdapter("", 
> ConfigurationManager.AppSettings("connectionstring"))
> sectionadapter.Fill(sectiontable)
> Me.datSection.DataSource = sectiontable
> Me.datSection.DataBind()
> End Sub
>
> Do any of these ideas or information help give a way to solve my problem? 
> Thanks.
> -- 
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
> "Cor Ligthert [MVP]"  wrote in message 
> news:%239YYxTWsHHA.4500@TK2MSFTNGP04.phx.gbl...
>> Nathan,
>>
>> Probably Ajax,  however I am seriously curious what a usercontrol for 
>> ASPNET has to do with ADONET.
>>
>> Cor
>>
>> "Nathan Sokalski"  schreef in bericht 
>> news:eTM78JIsHHA.4992@TK2MSFTNGP05.phx.gbl...
>>> Isn't there any kind of workaround? I am sure that I am not the first 
>>> person to want to maintain the properties of dynamically loaded 
>>> usercontrols between postbacks. Anybody have any ideas? Thanks.
>>> --
>>> Nathan Sokalski
>>> njsokalski@hotmail.com
>>> http://www.nathansokalski.com/
>>>
>>> "Masudur"  wrote in message 
>>> news:1181974218.719890.57440@o11g2000prd.googlegroups.com...
>>>> On Jun 16, 10:53 am, "Nathan Sokalski"  wrote:
>>>>> I have a page which I dynamically add several usercontrols (*.ascx 
>>>>> files) to
>>>>> using the following code:
>>>>>
>>>>>  Public Sub Refresh()
>>>>>   For Each section As DataRow In Me.GetSections().Rows
>>>>>    CType(Me.FindControl("admin" & 
>>>>> CStr(section("buttontext")).Replace(" ",
>>>>> "")), adminsection2).RefreshSection()
>>>>>   Next
>>>>>  End Sub
>>>>>
>>>>>  Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>>>> System.EventArgs) Handles Me.Load
>>>>>   Dim sections As DataTable = Me.GetSections()
>>>>>   For Each section As DataRow In sections.Rows
>>>>>    Me.AddAdminSection(CStr(section("buttontext")))
>>>>>   Next
>>>>>   Me.Refresh()
>>>>>  End Sub
>>>>>
>>>>>  Private Function GetSections() As DataTable
>>>>>   Dim sections As New DataTable
>>>>>   Dim dataadapterSelect As New OleDbDataAdapter("SELECT buttontext 
>>>>> FROM
>>>>> subnavigation WHERE buttontext<>'More.' AND category='" &
>>>>> Request.QueryString("category") & "' ORDER BY buttonorder",
>>>>> System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
>>>>>   dataadapterSelect.Fill(sections)
>>>>>   Return sections
>>>>>  End Function
>>>>>
>>>>>  Private Sub AddAdminSection(ByVal section As String)
>>>>>   Dim admin As adminsection2 =
>>>>> CType(Page.LoadControl("~/usercontrols/adminsection2.ascx"), 
>>>>> adminsection2)
>>>>>   admin.ID = "admin" & section.Replace(" ", "")
>>>>>   admin.Section = section
>>>>>   Me.form1.Controls.Add(admin)
>>>>>  End Sub
>>>>>
>>>>> My problem is that the controls are reloaded every time, as you can 
>>>>> see from
>>>>> the Load event. If I place the following line
>>>>>
>>>>> Me.AddAdminSection(CStr(section("buttontext")))
>>>>>
>>>>> in an If Not Me.IsPostBack() statement, then it is only loaded the 
>>>>> first
>>>>> time and I recieve an object does not exist error every time the 
>>>>> Refresh()
>>>>> method is called (which is reasonably often, because this is for an
>>>>> administration page where the user edits DB records). What can I do to
>>>>> maintain the look of the dynamically added controls (in other words, 
>>>>> how can
>>>>> I avoid replacing them with every postback)? If there is any other 
>>>>> code you
>>>>> need to see that might help, let me know. Thanks.
>>>>> --
>>>>> Nathan Sokalski
>>>>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>>>>
>>>> Hi,
>>>>
>>>> Dynamically loaded controls need to be load after each post back...
>>>> other wise dynamically loaded control's event wont work...
>>>> Its always a good practice to load the controls in page_init event
>>>>
>>>> Thanks
>>>> Masudur
>>>>
>>>
>>>
>>
>>
>
> 
Date:Tue, 19 Jun 2007 07:04:28 +0200   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us