Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problem with AddHandler (New CommandEventHandler) under framework 2.0

Reply
Thread Tools

Problem with AddHandler (New CommandEventHandler) under framework 2.0

 
 
Fabrice
Guest
Posts: n/a
 
      06-25-2009

Hello

This code works under framework 1.1. I add in the header an image with a
command event to execute a sub on click.
It work fine with 1.1. But not under 2.0.

I think the problem could be with the declaration :AddHandler
myBtnLibEveUp.Command, New CommandEventHandler(AddressOf myImgButtonSorting)

Is there a way to build a control and add an command handler ?

thanks for your help
fabrice


Code to add my first image button.

Sub my009DataGrid_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs)

If e.Item.ItemType = ListItemType.Header Then

'Add Control ImageButton UP LIBEVE.
Dim myBtnLibEveUp As New ImageButton
With myBtnLibEveUp
.ImageUrl="/img/gen/up.gif"
.EnableViewState = ctype("False",Boolean)
.CausesValidation=ctype("False",Boolean)
.Attributes.Add("runat", "server")
.Attributes.Add("onMouseOver", "window.status=' '; return true;")
.AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveUp","patent.aspx")
.Id="myBtnLibEveUp"
.CommandArgument="LIBEVE ASC"
AddHandler myBtnLibEveUp.Command, New CommandEventHandler(AddressOf
myImgButtonSorting)
End With

.....

The procedure :

Sub myImgButtonSorting (sender As Object, e As
System.Web.UI.WebControls.CommandEventArgs)

response.write("test")

end sud


 
Reply With Quote
 
 
 
 
Lloyd Sheen
Guest
Posts: n/a
 
      06-25-2009


"Fabrice" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello
>
> This code works under framework 1.1. I add in the header an image with a
> command event to execute a sub on click.
> It work fine with 1.1. But not under 2.0.
>
> I think the problem could be with the declaration :AddHandler
> myBtnLibEveUp.Command, New CommandEventHandler(AddressOf
> myImgButtonSorting)
>
> Is there a way to build a control and add an command handler ?
>
> thanks for your help
> fabrice
>
>
> Code to add my first image button.
>
> Sub my009DataGrid_ItemCreated(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.DataGridItemEventArgs)
>
> If e.Item.ItemType = ListItemType.Header Then
>
> 'Add Control ImageButton UP LIBEVE.
> Dim myBtnLibEveUp As New ImageButton
> With myBtnLibEveUp
> .ImageUrl="/img/gen/up.gif"
> .EnableViewState = ctype("False",Boolean)
> .CausesValidation=ctype("False",Boolean)
> .Attributes.Add("runat", "server")
> .Attributes.Add("onMouseOver", "window.status=' '; return true;")
>
> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveUp","patent.aspx")
> .Id="myBtnLibEveUp"
> .CommandArgument="LIBEVE ASC"
> AddHandler myBtnLibEveUp.Command, New CommandEventHandler(AddressOf
> myImgButtonSorting)
> End With
>
> ....
>
> The procedure :
>
> Sub myImgButtonSorting (sender As Object, e As
> System.Web.UI.WebControls.CommandEventArgs)
>
> response.write("test")
>
> end sud
>


I don't see any code to add the control to the page.

LS

 
Reply With Quote
 
 
 
 
Fabrice
Guest
Posts: n/a
 
      06-25-2009

Sorry. This is my code :

In my aspx file, I have a datagrid with the "OnItemCreated" parameter.
In my code behind (VB file), I have built all the buttons by code
(ImageButton).

The Handler on the differents ImageButtons seems not be fire under .net 2.0
It is ok under 1.1

In my datagrid The parameter OnItemCreated is
OnItemCreated="my009DataGrid_ItemCreated"
(see part 2)

part 1/ My code file in my .vb file
------------------------------------


Sub my009DataGrid_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs)

If e.Item.ItemType = ListItemType.Header Then

'ImageButton Header column : e.Item.Cells(0)

Dim myLibEve As New Label
With myLibEve
.Id="myLibEve"
.Text=myLocalization.EasyResourceManager.myGetStri ng("myLibEve","patent.aspx")
.EnableViewState = ctype("False",Boolean)
.CssClass="txtOres2"
.Attributes.Add("runat", "server")
End With

'ADD Control ImageButton UP LIBEVE.
Dim myBtnLibEveUp As New ImageButton
With myBtnLibEveUp
.ImageUrl="/img/gen/up.gif"
.EnableViewState = ctype("False",Boolean)
.CausesValidation=ctype("False",Boolean)
.Attributes.Add("runat", "server")
.Attributes.Add("onMouseOver", "window.status=' '; return true;")
.AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveUp","patent.aspx")
.Id="myBtnLibEveUp"
.CommandArgument="LIBEVE ASC"
AddHandler myBtnLibEveUp.Command, New CommandEventHandler(AddressOf
myImgButtonSorting)
End With

'ADD Control ImageButton DOWN LIBEVE.
Dim myBtnLibEveDown As New ImageButton
With myBtnLibEveDown
..ImageUrl="/img/gen/down.gif"
..EnableViewState = ctype("False",Boolean)
..CausesValidation=ctype("False",Boolean)
..Attributes.Add("runat", "server")
..Attributes.Add("onMouseOver", "window.status=' '; return true;")
..AlternateText=myLocalization.EasyResourceManager .myGetString("BtnLibEveDown","patent.aspx")
..Id="myBtnLibEveDown"
..CommandArgument="LIBEVE DESC"
AddHandler myBtnLibEveDown.Command, New CommandEventHandler(AddressOf
myImgButtonSorting)
End With

'Add controls in e.Item.Cells(0)
e.Item.Cells(0).Controls.Add(myLibEve)
e.Item.Cells(0).Controls.Add(myBtnLibEveUp)
e.Item.Cells(0).Controls.Add(myBtnLibEveDown)


myLibEve.Dispose()
myLibEve=Nothing
myBtnLibEveUp.Dispose()
myBtnLibEveUp=Nothing
myBtnLibEveDown.Dispose()
myBtnLibEveDown=Nothing

'Texte de la Colonne Header : e.Item.Cells(1)
'Label Colonne DATECH.
Dim myDatEch As New Label
With myDatEch
.Id="myDatEch"
.Text=myLocalization.EasyResourceManager.myGetStri ng("myDatEch","patent.aspx")
.EnableViewState = ctype("False",Boolean)
.CssClass="txtOres2"
.Attributes.Add("runat", "server")
End With

'Ajout Control ImageButton UP DATECH.
Dim myBtnDatEchUp As New ImageButton
With myBtnDatEchUp
.ImageUrl="/img/gen/up.gif"
.EnableViewState = ctype("False",Boolean)
.CausesValidation=ctype("False",Boolean)
.Attributes.Add("runat", "server")
.Attributes.Add("onMouseOver", "window.status=' '; return true;")
.AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveUp","patent.aspx")
.Id="myBtnDatEchUp"
.CommandArgument="DATECH ASC"
AddHandler myBtnDatEchUp.Command, New CommandEventHandler(AddressOf
myImgButtonSorting)
End With

'Ajout Control ImageButton DOWN DATECH.
Dim myBtnDatEchDown As New ImageButton
With myBtnDatEchDown
.ImageUrl="/img/gen/down.gif"
.EnableViewState = ctype("False",Boolean)
.CausesValidation=ctype("False",Boolean)
.Attributes.Add("runat", "server")
.Attributes.Add("onMouseOver", "window.status=' '; return true;")
.AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveDown","patent.aspx")
.Id="myBtnDatEchDown"
.CommandArgument="DATECH DESC"
AddHandler myBtnDatEchDown.Command, New CommandEventHandler(AddressOf
myImgButtonSorting)
End With

'Ajout Effectif dans e.Item.Cells(0)
e.Item.Cells(1).Controls.Add(myDatEch)
e.Item.Cells(1).Controls.Add(myBtnDatEchUp)
e.Item.Cells(1).Controls.Add(myBtnDatEchDown)

'Libération Mémoire des trois Controls
myDatEch.Dispose()
myDatEch=Nothing
myBtnDatEchUp.Dispose()
myBtnDatEchUp=Nothing
myBtnDatEchDown.Dispose()
myBtnDatEchDown=Nothing

'Texte de la Colonne Header : e.Item.Cells(2)
'Label Colonne NATURE.
Dim myNature As New Label
With myNature
.Id="myNature"
.Text=myLocalization.EasyResourceManager.myGetStri ng("myNature","patent.aspx")
.EnableViewState = ctype("False",Boolean)
.CssClass="txtOres2"
.Attributes.Add("runat", "server")
End With

'Ajout Effectif dans e.Item.Cells(0)
e.Item.Cells(2).Controls.Add(myNature)

'Libération Mémoire des trois Controls
myNature.Dispose()
myNature=Nothing

End If '.Item.ItemType = ListItemType.Header

End Sub 'my009DataGrid_ItemCreated


part 2/ In .aspx file : My datagrid with OnItemCreated parameter

<aspataGrid id="my009DataGrid"
runat="server"
FooterStyle-BorderWidth="0"
ShowFooter="False"
FooterStyle-BackColor="#F29168"
FooterStyle-ForeColor="#FFFFFF"
FooterStyle-BorderStyle= "None"
PagerStyle-Mode="NumericPages"
PageCount="1"
AutoGenerateColumns="False"
borderwidth="1"
bordercolor="black"
BorderStyle="Solid"
PagerStyle-VerticalAlign="top"
Cellpadding="1"
Cellspacing="0"
ShowHeader="True"
HeaderStyle-ForeColor="White"
HeaderStyle-Font-Bold="False"
HeaderStyle-HorizontalAlign="Center"
HeaderStyle-VerticalAlign="Middle"
AllowSorting="False"
AllowPaging="True"
OnPageIndexChanged="PageIndexChanged_OnClick"
OnItemCreated="my009DataGrid_ItemCreated"
PageSize="5"
width="100%"
HeaderStyle-BackColor="#93b0cc"
BackColor="#e5ecf2"
AlternatingItemStyle-BackColor="#e5ecf2"
PagerStyle-Backcolor="#93b0cc"
PagerStyle-Forecolor="Black"
PagerStyle-HorizontalAlign="Right"
PagerStyle-BorderStyle="Inset">

<Columns>
<asp:BoundColumn DataField="libeve" ReadOnly="true">
<ItemStyle Font-Names="Times New Roman, Times, serif" ForeColor="#003B6F"
Font-Size="10" horizontalalign="Left" VerticalAlign="Middle" width="40%">
</ItemStyle>
</asp:BoundColumn>

<asp:BoundColumn DataField="datech" DataFormatString="{0:d}"
ReadOnly="true">
<ItemStyle Font-Names="Times New Roman, Times, serif" ForeColor="#003B6F"
Font-Size="10" horizontalalign="Center" VerticalAlign="Middle" width="30%">
</ItemStyle>
</asp:BoundColumn>

<asp:BoundColumn DataField="nature" ReadOnly="true" HeaderText="Nature">
<ItemStyle Font-Names="Times New Roman, Times, serif" ForeColor="#003B6F"
Font-Size="10" horizontalalign="Center" VerticalAlign="Middle" width="30%">
</ItemStyle>
</asp:BoundColumn>
</Columns>

</aspataGrid>



thanks for your help
 
Reply With Quote
 
Lloyd Sheen
Guest
Posts: n/a
 
      06-25-2009


"Fabrice" <(E-Mail Removed)> wrote in message
news:us%(E-Mail Removed)...
> Sorry. This is my code :
>
> In my aspx file, I have a datagrid with the "OnItemCreated" parameter.
> In my code behind (VB file), I have built all the buttons by code
> (ImageButton).
>
> The Handler on the differents ImageButtons seems not be fire under .net
> 2.0
> It is ok under 1.1
>
> In my datagrid The parameter OnItemCreated is
> OnItemCreated="my009DataGrid_ItemCreated"
> (see part 2)
>
> part 1/ My code file in my .vb file
> ------------------------------------
>
>
> Sub my009DataGrid_ItemCreated(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.DataGridItemEventArgs)
>
> If e.Item.ItemType = ListItemType.Header Then
>
> 'ImageButton Header column : e.Item.Cells(0)
>
> Dim myLibEve As New Label
> With myLibEve
> .Id="myLibEve"
>
> .Text=myLocalization.EasyResourceManager.myGetStri ng("myLibEve","patent.aspx")
> .EnableViewState = ctype("False",Boolean)
> .CssClass="txtOres2"
> .Attributes.Add("runat", "server")
> End With
>
> 'ADD Control ImageButton UP LIBEVE.
> Dim myBtnLibEveUp As New ImageButton
> With myBtnLibEveUp
> .ImageUrl="/img/gen/up.gif"
> .EnableViewState = ctype("False",Boolean)
> .CausesValidation=ctype("False",Boolean)
> .Attributes.Add("runat", "server")
> .Attributes.Add("onMouseOver", "window.status=' '; return true;")
>
> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveUp","patent.aspx")
> .Id="myBtnLibEveUp"
> .CommandArgument="LIBEVE ASC"
> AddHandler myBtnLibEveUp.Command, New CommandEventHandler(AddressOf
> myImgButtonSorting)
> End With
>
> 'ADD Control ImageButton DOWN LIBEVE.
> Dim myBtnLibEveDown As New ImageButton
> With myBtnLibEveDown
> .ImageUrl="/img/gen/down.gif"
> .EnableViewState = ctype("False",Boolean)
> .CausesValidation=ctype("False",Boolean)
> .Attributes.Add("runat", "server")
> .Attributes.Add("onMouseOver", "window.status=' '; return true;")
> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveDown","patent.aspx")
> .Id="myBtnLibEveDown"
> .CommandArgument="LIBEVE DESC"
> AddHandler myBtnLibEveDown.Command, New CommandEventHandler(AddressOf
> myImgButtonSorting)
> End With
>
> 'Add controls in e.Item.Cells(0)
> e.Item.Cells(0).Controls.Add(myLibEve)
> e.Item.Cells(0).Controls.Add(myBtnLibEveUp)
> e.Item.Cells(0).Controls.Add(myBtnLibEveDown)
>
>
> myLibEve.Dispose()
> myLibEve=Nothing
> myBtnLibEveUp.Dispose()
> myBtnLibEveUp=Nothing
> myBtnLibEveDown.Dispose()
> myBtnLibEveDown=Nothing
>
> 'Texte de la Colonne Header : e.Item.Cells(1)
> 'Label Colonne DATECH.
> Dim myDatEch As New Label
> With myDatEch
> .Id="myDatEch"
>
> .Text=myLocalization.EasyResourceManager.myGetStri ng("myDatEch","patent.aspx")
> .EnableViewState = ctype("False",Boolean)
> .CssClass="txtOres2"
> .Attributes.Add("runat", "server")
> End With
>
> 'Ajout Control ImageButton UP DATECH.
> Dim myBtnDatEchUp As New ImageButton
> With myBtnDatEchUp
> .ImageUrl="/img/gen/up.gif"
> .EnableViewState = ctype("False",Boolean)
> .CausesValidation=ctype("False",Boolean)
> .Attributes.Add("runat", "server")
> .Attributes.Add("onMouseOver", "window.status=' '; return
> true;")
>
> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveUp","patent.aspx")
> .Id="myBtnDatEchUp"
> .CommandArgument="DATECH ASC"
> AddHandler myBtnDatEchUp.Command, New
> CommandEventHandler(AddressOf
> myImgButtonSorting)
> End With
>
> 'Ajout Control ImageButton DOWN DATECH.
> Dim myBtnDatEchDown As New ImageButton
> With myBtnDatEchDown
> .ImageUrl="/img/gen/down.gif"
> .EnableViewState = ctype("False",Boolean)
> .CausesValidation=ctype("False",Boolean)
> .Attributes.Add("runat", "server")
> .Attributes.Add("onMouseOver", "window.status=' '; return
> true;")
>
> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveDown","patent.aspx")
> .Id="myBtnDatEchDown"
> .CommandArgument="DATECH DESC"
> AddHandler myBtnDatEchDown.Command, New
> CommandEventHandler(AddressOf
> myImgButtonSorting)
> End With
>
> 'Ajout Effectif dans e.Item.Cells(0)
> e.Item.Cells(1).Controls.Add(myDatEch)
> e.Item.Cells(1).Controls.Add(myBtnDatEchUp)
> e.Item.Cells(1).Controls.Add(myBtnDatEchDown)
>
> 'Libération Mémoire des trois Controls
> myDatEch.Dispose()
> myDatEch=Nothing
> myBtnDatEchUp.Dispose()
> myBtnDatEchUp=Nothing
> myBtnDatEchDown.Dispose()
> myBtnDatEchDown=Nothing
>
> 'Texte de la Colonne Header : e.Item.Cells(2)
> 'Label Colonne NATURE.
> Dim myNature As New Label
> With myNature
> .Id="myNature"
>
> .Text=myLocalization.EasyResourceManager.myGetStri ng("myNature","patent.aspx")
> .EnableViewState = ctype("False",Boolean)
> .CssClass="txtOres2"
> .Attributes.Add("runat", "server")
> End With
>
> 'Ajout Effectif dans e.Item.Cells(0)
> e.Item.Cells(2).Controls.Add(myNature)
>
> 'Libération Mémoire des trois Controls
> myNature.Dispose()
> myNature=Nothing
>
> End If '.Item.ItemType = ListItemType.Header
>
> End Sub 'my009DataGrid_ItemCreated
>
>
> part 2/ In .aspx file : My datagrid with OnItemCreated parameter
>
> <aspataGrid id="my009DataGrid"
> runat="server"
> FooterStyle-BorderWidth="0"
> ShowFooter="False"
> FooterStyle-BackColor="#F29168"
> FooterStyle-ForeColor="#FFFFFF"
> FooterStyle-BorderStyle= "None"
> PagerStyle-Mode="NumericPages"
> PageCount="1"
> AutoGenerateColumns="False"
> borderwidth="1"
> bordercolor="black"
> BorderStyle="Solid"
> PagerStyle-VerticalAlign="top"
> Cellpadding="1"
> Cellspacing="0"
> ShowHeader="True"
> HeaderStyle-ForeColor="White"
> HeaderStyle-Font-Bold="False"
> HeaderStyle-HorizontalAlign="Center"
> HeaderStyle-VerticalAlign="Middle"
> AllowSorting="False"
> AllowPaging="True"
> OnPageIndexChanged="PageIndexChanged_OnClick"
> OnItemCreated="my009DataGrid_ItemCreated"
> PageSize="5"
> width="100%"
> HeaderStyle-BackColor="#93b0cc"
> BackColor="#e5ecf2"
> AlternatingItemStyle-BackColor="#e5ecf2"
> PagerStyle-Backcolor="#93b0cc"
> PagerStyle-Forecolor="Black"
> PagerStyle-HorizontalAlign="Right"
> PagerStyle-BorderStyle="Inset">
>
> <Columns>
> <asp:BoundColumn DataField="libeve" ReadOnly="true">
> <ItemStyle Font-Names="Times New Roman, Times, serif" ForeColor="#003B6F"
> Font-Size="10" horizontalalign="Left" VerticalAlign="Middle" width="40%">
> </ItemStyle>
> </asp:BoundColumn>
>
> <asp:BoundColumn DataField="datech" DataFormatString="{0:d}"
> ReadOnly="true">
> <ItemStyle Font-Names="Times New Roman, Times, serif" ForeColor="#003B6F"
> Font-Size="10" horizontalalign="Center" VerticalAlign="Middle"
> width="30%">
> </ItemStyle>
> </asp:BoundColumn>
>
> <asp:BoundColumn DataField="nature" ReadOnly="true" HeaderText="Nature">
> <ItemStyle Font-Names="Times New Roman, Times, serif" ForeColor="#003B6F"
> Font-Size="10" horizontalalign="Center" VerticalAlign="Middle"
> width="30%">
> </ItemStyle>
> </asp:BoundColumn>
> </Columns>
>
> </aspataGrid>
>
>
>
> thanks for your help


I wonder why you are doing the dispose of the controls you create, I would
think that one of the things that a dispose would do is remove all handlers.

Hope this helps
LS

 
Reply With Quote
 
Fabrice
Guest
Posts: n/a
 
      06-25-2009

Hello Lloyd

Your are right. I removed the "dispose" of the controls I have created.
And It works. I don't understand the difference of behavior between
framework 1.1 and 2.0.

If your can explain me.

Thanks
fabrice

> think that one of the things that a dispose would do is remove all
> handlers.


Lloyd Sheen wrote:

>
> "Fabrice" <(E-Mail Removed)> wrote in message
> news:us%(E-Mail Removed)...
>> Sorry. This is my code :
>>
>> In my aspx file, I have a datagrid with the "OnItemCreated" parameter.
>> In my code behind (VB file), I have built all the buttons by code
>> (ImageButton).
>>
>> The Handler on the differents ImageButtons seems not be fire under .net
>> 2.0
>> It is ok under 1.1
>>
>> In my datagrid The parameter OnItemCreated is
>> OnItemCreated="my009DataGrid_ItemCreated"
>> (see part 2)
>>
>> part 1/ My code file in my .vb file
>> ------------------------------------
>>
>>
>> Sub my009DataGrid_ItemCreated(ByVal sender As Object, ByVal e As
>> System.Web.UI.WebControls.DataGridItemEventArgs)
>>
>> If e.Item.ItemType = ListItemType.Header Then
>>
>> 'ImageButton Header column : e.Item.Cells(0)
>>
>> Dim myLibEve As New Label
>> With myLibEve
>> .Id="myLibEve"
>>
>> .Text=myLocalization.EasyResourceManager.myGetStri ng("myLibEve","patent.aspx")
>> .EnableViewState = ctype("False",Boolean)
>> .CssClass="txtOres2"
>> .Attributes.Add("runat", "server")
>> End With
>>
>> 'ADD Control ImageButton UP LIBEVE.
>> Dim myBtnLibEveUp As New ImageButton
>> With myBtnLibEveUp
>> .ImageUrl="/img/gen/up.gif"
>> .EnableViewState = ctype("False",Boolean)
>> .CausesValidation=ctype("False",Boolean)
>> .Attributes.Add("runat", "server")
>> .Attributes.Add("onMouseOver", "window.status=' '; return true;")
>>
>> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveUp","patent.aspx")
>> .Id="myBtnLibEveUp"
>> .CommandArgument="LIBEVE ASC"
>> AddHandler myBtnLibEveUp.Command, New CommandEventHandler(AddressOf
>> myImgButtonSorting)
>> End With
>>
>> 'ADD Control ImageButton DOWN LIBEVE.
>> Dim myBtnLibEveDown As New ImageButton
>> With myBtnLibEveDown
>> .ImageUrl="/img/gen/down.gif"
>> .EnableViewState = ctype("False",Boolean)
>> .CausesValidation=ctype("False",Boolean)
>> .Attributes.Add("runat", "server")
>> .Attributes.Add("onMouseOver", "window.status=' '; return true;")
>> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveDown","patent.aspx")
>> .Id="myBtnLibEveDown"
>> .CommandArgument="LIBEVE DESC"
>> AddHandler myBtnLibEveDown.Command, New CommandEventHandler(AddressOf
>> myImgButtonSorting)
>> End With
>>
>> 'Add controls in e.Item.Cells(0)
>> e.Item.Cells(0).Controls.Add(myLibEve)
>> e.Item.Cells(0).Controls.Add(myBtnLibEveUp)
>> e.Item.Cells(0).Controls.Add(myBtnLibEveDown)
>>
>>
>> myLibEve.Dispose()
>> myLibEve=Nothing
>> myBtnLibEveUp.Dispose()
>> myBtnLibEveUp=Nothing
>> myBtnLibEveDown.Dispose()
>> myBtnLibEveDown=Nothing
>>
>> 'Texte de la Colonne Header : e.Item.Cells(1)
>> 'Label Colonne DATECH.
>> Dim myDatEch As New Label
>> With myDatEch
>> .Id="myDatEch"
>>
>> .Text=myLocalization.EasyResourceManager.myGetStri ng("myDatEch","patent.aspx")
>> .EnableViewState = ctype("False",Boolean)
>> .CssClass="txtOres2"
>> .Attributes.Add("runat", "server")
>> End With
>>
>> 'Ajout Control ImageButton UP DATECH.
>> Dim myBtnDatEchUp As New ImageButton
>> With myBtnDatEchUp
>> .ImageUrl="/img/gen/up.gif"
>> .EnableViewState = ctype("False",Boolean)
>> .CausesValidation=ctype("False",Boolean)
>> .Attributes.Add("runat", "server")
>> .Attributes.Add("onMouseOver", "window.status=' '; return
>> true;")
>>
>> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveUp","patent.aspx")
>> .Id="myBtnDatEchUp"
>> .CommandArgument="DATECH ASC"
>> AddHandler myBtnDatEchUp.Command, New
>> CommandEventHandler(AddressOf
>> myImgButtonSorting)
>> End With
>>
>> 'Ajout Control ImageButton DOWN DATECH.
>> Dim myBtnDatEchDown As New ImageButton
>> With myBtnDatEchDown
>> .ImageUrl="/img/gen/down.gif"
>> .EnableViewState = ctype("False",Boolean)
>> .CausesValidation=ctype("False",Boolean)
>> .Attributes.Add("runat", "server")
>> .Attributes.Add("onMouseOver", "window.status=' '; return
>> true;")
>>
>> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveDown","patent.aspx")
>> .Id="myBtnDatEchDown"
>> .CommandArgument="DATECH DESC"
>> AddHandler myBtnDatEchDown.Command, New
>> CommandEventHandler(AddressOf
>> myImgButtonSorting)
>> End With
>>
>> 'Ajout Effectif dans e.Item.Cells(0)
>> e.Item.Cells(1).Controls.Add(myDatEch)
>> e.Item.Cells(1).Controls.Add(myBtnDatEchUp)
>> e.Item.Cells(1).Controls.Add(myBtnDatEchDown)
>>
>> 'Libération Mémoire des trois Controls
>> myDatEch.Dispose()
>> myDatEch=Nothing
>> myBtnDatEchUp.Dispose()
>> myBtnDatEchUp=Nothing
>> myBtnDatEchDown.Dispose()
>> myBtnDatEchDown=Nothing
>>
>> 'Texte de la Colonne Header : e.Item.Cells(2)
>> 'Label Colonne NATURE.
>> Dim myNature As New Label
>> With myNature
>> .Id="myNature"
>>
>> .Text=myLocalization.EasyResourceManager.myGetStri ng("myNature","patent.aspx")
>> .EnableViewState = ctype("False",Boolean)
>> .CssClass="txtOres2"
>> .Attributes.Add("runat", "server")
>> End With
>>
>> 'Ajout Effectif dans e.Item.Cells(0)
>> e.Item.Cells(2).Controls.Add(myNature)
>>
>> 'Libération Mémoire des trois Controls
>> myNature.Dispose()
>> myNature=Nothing
>>
>> End If '.Item.ItemType = ListItemType.Header
>>
>> End Sub 'my009DataGrid_ItemCreated
>>
>>
>> part 2/ In .aspx file : My datagrid with OnItemCreated parameter
>>
>> <aspataGrid id="my009DataGrid"
>> runat="server"
>> FooterStyle-BorderWidth="0"
>> ShowFooter="False"
>> FooterStyle-BackColor="#F29168"
>> FooterStyle-ForeColor="#FFFFFF"
>> FooterStyle-BorderStyle= "None"
>> PagerStyle-Mode="NumericPages"
>> PageCount="1"
>> AutoGenerateColumns="False"
>> borderwidth="1"
>> bordercolor="black"
>> BorderStyle="Solid"
>> PagerStyle-VerticalAlign="top"
>> Cellpadding="1"
>> Cellspacing="0"
>> ShowHeader="True"
>> HeaderStyle-ForeColor="White"
>> HeaderStyle-Font-Bold="False"
>> HeaderStyle-HorizontalAlign="Center"
>> HeaderStyle-VerticalAlign="Middle"
>> AllowSorting="False"
>> AllowPaging="True"
>> OnPageIndexChanged="PageIndexChanged_OnClick"
>> OnItemCreated="my009DataGrid_ItemCreated"
>> PageSize="5"
>> width="100%"
>> HeaderStyle-BackColor="#93b0cc"
>> BackColor="#e5ecf2"
>> AlternatingItemStyle-BackColor="#e5ecf2"
>> PagerStyle-Backcolor="#93b0cc"
>> PagerStyle-Forecolor="Black"
>> PagerStyle-HorizontalAlign="Right"
>> PagerStyle-BorderStyle="Inset">
>>
>> <Columns>
>> <asp:BoundColumn DataField="libeve" ReadOnly="true">
>> <ItemStyle Font-Names="Times New Roman, Times, serif" ForeColor="#003B6F"
>> Font-Size="10" horizontalalign="Left" VerticalAlign="Middle" width="40%">
>> </ItemStyle>
>> </asp:BoundColumn>
>>
>> <asp:BoundColumn DataField="datech" DataFormatString="{0:d}"
>> ReadOnly="true">
>> <ItemStyle Font-Names="Times New Roman, Times, serif" ForeColor="#003B6F"
>> Font-Size="10" horizontalalign="Center" VerticalAlign="Middle"
>> width="30%">
>> </ItemStyle>
>> </asp:BoundColumn>
>>
>> <asp:BoundColumn DataField="nature" ReadOnly="true" HeaderText="Nature">
>> <ItemStyle Font-Names="Times New Roman, Times, serif" ForeColor="#003B6F"
>> Font-Size="10" horizontalalign="Center" VerticalAlign="Middle"
>> width="30%">
>> </ItemStyle>
>> </asp:BoundColumn>
>> </Columns>
>>
>> </aspataGrid>
>>
>>
>>
>> thanks for your help

>
> I wonder why you are doing the dispose of the controls you create, I would
> think that one of the things that a dispose would do is remove all
> handlers.
>
> Hope this helps
> LS


 
Reply With Quote
 
Lloyd Sheen
Guest
Posts: n/a
 
      06-25-2009


"Fabrice" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello Lloyd
>
> Your are right. I removed the "dispose" of the controls I have created.
> And It works. I don't understand the difference of behavior between
> framework 1.1 and 2.0.
>
> If your can explain me.
>
> Thanks
> fabrice
>
>> think that one of the things that a dispose would do is remove all
>> handlers.

>
> Lloyd Sheen wrote:
>
>>
>> "Fabrice" <(E-Mail Removed)> wrote in message
>> news:us%(E-Mail Removed)...
>>> Sorry. This is my code :
>>>
>>> In my aspx file, I have a datagrid with the "OnItemCreated" parameter.
>>> In my code behind (VB file), I have built all the buttons by code
>>> (ImageButton).
>>>
>>> The Handler on the differents ImageButtons seems not be fire under .net
>>> 2.0
>>> It is ok under 1.1
>>>
>>> In my datagrid The parameter OnItemCreated is
>>> OnItemCreated="my009DataGrid_ItemCreated"
>>> (see part 2)
>>>
>>> part 1/ My code file in my .vb file
>>> ------------------------------------
>>>
>>>
>>> Sub my009DataGrid_ItemCreated(ByVal sender As Object, ByVal e As
>>> System.Web.UI.WebControls.DataGridItemEventArgs)
>>>
>>> If e.Item.ItemType = ListItemType.Header Then
>>>
>>> 'ImageButton Header column : e.Item.Cells(0)
>>>
>>> Dim myLibEve As New Label
>>> With myLibEve
>>> .Id="myLibEve"
>>>
>>> .Text=myLocalization.EasyResourceManager.myGetStri ng("myLibEve","patent.aspx")
>>> .EnableViewState = ctype("False",Boolean)
>>> .CssClass="txtOres2"
>>> .Attributes.Add("runat", "server")
>>> End With
>>>
>>> 'ADD Control ImageButton UP LIBEVE.
>>> Dim myBtnLibEveUp As New ImageButton
>>> With myBtnLibEveUp
>>> .ImageUrl="/img/gen/up.gif"
>>> .EnableViewState = ctype("False",Boolean)
>>> .CausesValidation=ctype("False",Boolean)
>>> .Attributes.Add("runat", "server")
>>> .Attributes.Add("onMouseOver", "window.status=' '; return true;")
>>>
>>> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveUp","patent.aspx")
>>> .Id="myBtnLibEveUp"
>>> .CommandArgument="LIBEVE ASC"
>>> AddHandler myBtnLibEveUp.Command, New CommandEventHandler(AddressOf
>>> myImgButtonSorting)
>>> End With
>>>
>>> 'ADD Control ImageButton DOWN LIBEVE.
>>> Dim myBtnLibEveDown As New ImageButton
>>> With myBtnLibEveDown
>>> .ImageUrl="/img/gen/down.gif"
>>> .EnableViewState = ctype("False",Boolean)
>>> .CausesValidation=ctype("False",Boolean)
>>> .Attributes.Add("runat", "server")
>>> .Attributes.Add("onMouseOver", "window.status=' '; return true;")
>>> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveDown","patent.aspx")
>>> .Id="myBtnLibEveDown"
>>> .CommandArgument="LIBEVE DESC"
>>> AddHandler myBtnLibEveDown.Command, New CommandEventHandler(AddressOf
>>> myImgButtonSorting)
>>> End With
>>>
>>> 'Add controls in e.Item.Cells(0)
>>> e.Item.Cells(0).Controls.Add(myLibEve)
>>> e.Item.Cells(0).Controls.Add(myBtnLibEveUp)
>>> e.Item.Cells(0).Controls.Add(myBtnLibEveDown)
>>>
>>>
>>> myLibEve.Dispose()
>>> myLibEve=Nothing
>>> myBtnLibEveUp.Dispose()
>>> myBtnLibEveUp=Nothing
>>> myBtnLibEveDown.Dispose()
>>> myBtnLibEveDown=Nothing
>>>
>>> 'Texte de la Colonne Header : e.Item.Cells(1)
>>> 'Label Colonne DATECH.
>>> Dim myDatEch As New Label
>>> With myDatEch
>>> .Id="myDatEch"
>>>
>>> .Text=myLocalization.EasyResourceManager.myGetStri ng("myDatEch","patent.aspx")
>>> .EnableViewState = ctype("False",Boolean)
>>> .CssClass="txtOres2"
>>> .Attributes.Add("runat", "server")
>>> End With
>>>
>>> 'Ajout Control ImageButton UP DATECH.
>>> Dim myBtnDatEchUp As New ImageButton
>>> With myBtnDatEchUp
>>> .ImageUrl="/img/gen/up.gif"
>>> .EnableViewState = ctype("False",Boolean)
>>> .CausesValidation=ctype("False",Boolean)
>>> .Attributes.Add("runat", "server")
>>> .Attributes.Add("onMouseOver", "window.status=' '; return
>>> true;")
>>>
>>> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveUp","patent.aspx")
>>> .Id="myBtnDatEchUp"
>>> .CommandArgument="DATECH ASC"
>>> AddHandler myBtnDatEchUp.Command, New
>>> CommandEventHandler(AddressOf
>>> myImgButtonSorting)
>>> End With
>>>
>>> 'Ajout Control ImageButton DOWN DATECH.
>>> Dim myBtnDatEchDown As New ImageButton
>>> With myBtnDatEchDown
>>> .ImageUrl="/img/gen/down.gif"
>>> .EnableViewState = ctype("False",Boolean)
>>> .CausesValidation=ctype("False",Boolean)
>>> .Attributes.Add("runat", "server")
>>> .Attributes.Add("onMouseOver", "window.status=' '; return
>>> true;")
>>>
>>> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveDown","patent.aspx")
>>> .Id="myBtnDatEchDown"
>>> .CommandArgument="DATECH DESC"
>>> AddHandler myBtnDatEchDown.Command, New
>>> CommandEventHandler(AddressOf
>>> myImgButtonSorting)
>>> End With
>>>
>>> 'Ajout Effectif dans e.Item.Cells(0)
>>> e.Item.Cells(1).Controls.Add(myDatEch)
>>> e.Item.Cells(1).Controls.Add(myBtnDatEchUp)
>>> e.Item.Cells(1).Controls.Add(myBtnDatEchDown)
>>>
>>> 'Libération Mémoire des trois Controls
>>> myDatEch.Dispose()
>>> myDatEch=Nothing
>>> myBtnDatEchUp.Dispose()
>>> myBtnDatEchUp=Nothing
>>> myBtnDatEchDown.Dispose()
>>> myBtnDatEchDown=Nothing
>>>
>>> 'Texte de la Colonne Header : e.Item.Cells(2)
>>> 'Label Colonne NATURE.
>>> Dim myNature As New Label
>>> With myNature
>>> .Id="myNature"
>>>
>>> .Text=myLocalization.EasyResourceManager.myGetStri ng("myNature","patent.aspx")
>>> .EnableViewState = ctype("False",Boolean)
>>> .CssClass="txtOres2"
>>> .Attributes.Add("runat", "server")
>>> End With
>>>
>>> 'Ajout Effectif dans e.Item.Cells(0)
>>> e.Item.Cells(2).Controls.Add(myNature)
>>>
>>> 'Libération Mémoire des trois Controls
>>> myNature.Dispose()
>>> myNature=Nothing
>>>
>>> End If '.Item.ItemType = ListItemType.Header
>>>
>>> End Sub 'my009DataGrid_ItemCreated
>>>
>>>
>>> part 2/ In .aspx file : My datagrid with OnItemCreated parameter
>>>
>>> <aspataGrid id="my009DataGrid"
>>> runat="server"
>>> FooterStyle-BorderWidth="0"
>>> ShowFooter="False"
>>> FooterStyle-BackColor="#F29168"
>>> FooterStyle-ForeColor="#FFFFFF"
>>> FooterStyle-BorderStyle= "None"
>>> PagerStyle-Mode="NumericPages"
>>> PageCount="1"
>>> AutoGenerateColumns="False"
>>> borderwidth="1"
>>> bordercolor="black"
>>> BorderStyle="Solid"
>>> PagerStyle-VerticalAlign="top"
>>> Cellpadding="1"
>>> Cellspacing="0"
>>> ShowHeader="True"
>>> HeaderStyle-ForeColor="White"
>>> HeaderStyle-Font-Bold="False"
>>> HeaderStyle-HorizontalAlign="Center"
>>> HeaderStyle-VerticalAlign="Middle"
>>> AllowSorting="False"
>>> AllowPaging="True"
>>> OnPageIndexChanged="PageIndexChanged_OnClick"
>>> OnItemCreated="my009DataGrid_ItemCreated"
>>> PageSize="5"
>>> width="100%"
>>> HeaderStyle-BackColor="#93b0cc"
>>> BackColor="#e5ecf2"
>>> AlternatingItemStyle-BackColor="#e5ecf2"
>>> PagerStyle-Backcolor="#93b0cc"
>>> PagerStyle-Forecolor="Black"
>>> PagerStyle-HorizontalAlign="Right"
>>> PagerStyle-BorderStyle="Inset">
>>>
>>> <Columns>
>>> <asp:BoundColumn DataField="libeve" ReadOnly="true">
>>> <ItemStyle Font-Names="Times New Roman, Times, serif"
>>> ForeColor="#003B6F"
>>> Font-Size="10" horizontalalign="Left" VerticalAlign="Middle"
>>> width="40%">
>>> </ItemStyle>
>>> </asp:BoundColumn>
>>>
>>> <asp:BoundColumn DataField="datech" DataFormatString="{0:d}"
>>> ReadOnly="true">
>>> <ItemStyle Font-Names="Times New Roman, Times, serif"
>>> ForeColor="#003B6F"
>>> Font-Size="10" horizontalalign="Center" VerticalAlign="Middle"
>>> width="30%">
>>> </ItemStyle>
>>> </asp:BoundColumn>
>>>
>>> <asp:BoundColumn DataField="nature" ReadOnly="true"
>>> HeaderText="Nature">
>>> <ItemStyle Font-Names="Times New Roman, Times, serif"
>>> ForeColor="#003B6F"
>>> Font-Size="10" horizontalalign="Center" VerticalAlign="Middle"
>>> width="30%">
>>> </ItemStyle>
>>> </asp:BoundColumn>
>>> </Columns>
>>>
>>> </aspataGrid>
>>>
>>>
>>>
>>> thanks for your help

>>
>> I wonder why you are doing the dispose of the controls you create, I
>> would
>> think that one of the things that a dispose would do is remove all
>> handlers.
>>
>> Hope this helps
>> LS

>


Don't take this a gospel but it looks like in 1.1 the dispose did not remove
the handler. That is only conjecture but I am glad that fixed the problem.

LS

 
Reply With Quote
 
kaushik
Guest
Posts: n/a
 
      06-26-2009

thanks

"Lloyd Sheen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> "Fabrice" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hello Lloyd
>>
>> Your are right. I removed the "dispose" of the controls I have created.
>> And It works. I don't understand the difference of behavior between
>> framework 1.1 and 2.0.
>>
>> If your can explain me.
>>
>> Thanks
>> fabrice
>>
>>> think that one of the things that a dispose would do is remove all
>>> handlers.

>>
>> Lloyd Sheen wrote:
>>
>>>
>>> "Fabrice" <(E-Mail Removed)> wrote in message
>>> news:us%(E-Mail Removed)...
>>>> Sorry. This is my code :
>>>>
>>>> In my aspx file, I have a datagrid with the "OnItemCreated" parameter.
>>>> In my code behind (VB file), I have built all the buttons by code
>>>> (ImageButton).
>>>>
>>>> The Handler on the differents ImageButtons seems not be fire under .net
>>>> 2.0
>>>> It is ok under 1.1
>>>>
>>>> In my datagrid The parameter OnItemCreated is
>>>> OnItemCreated="my009DataGrid_ItemCreated"
>>>> (see part 2)
>>>>
>>>> part 1/ My code file in my .vb file
>>>> ------------------------------------
>>>>
>>>>
>>>> Sub my009DataGrid_ItemCreated(ByVal sender As Object, ByVal e As
>>>> System.Web.UI.WebControls.DataGridItemEventArgs)
>>>>
>>>> If e.Item.ItemType = ListItemType.Header Then
>>>>
>>>> 'ImageButton Header column : e.Item.Cells(0)
>>>>
>>>> Dim myLibEve As New Label
>>>> With myLibEve
>>>> .Id="myLibEve"
>>>>
>>>> .Text=myLocalization.EasyResourceManager.myGetStri ng("myLibEve","patent.aspx")
>>>> .EnableViewState = ctype("False",Boolean)
>>>> .CssClass="txtOres2"
>>>> .Attributes.Add("runat", "server")
>>>> End With
>>>>
>>>> 'ADD Control ImageButton UP LIBEVE.
>>>> Dim myBtnLibEveUp As New ImageButton
>>>> With myBtnLibEveUp
>>>> .ImageUrl="/img/gen/up.gif"
>>>> .EnableViewState = ctype("False",Boolean)
>>>> .CausesValidation=ctype("False",Boolean)
>>>> .Attributes.Add("runat", "server")
>>>> .Attributes.Add("onMouseOver", "window.status=' '; return true;")
>>>>
>>>> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveUp","patent.aspx")
>>>> .Id="myBtnLibEveUp"
>>>> .CommandArgument="LIBEVE ASC"
>>>> AddHandler myBtnLibEveUp.Command, New CommandEventHandler(AddressOf
>>>> myImgButtonSorting)
>>>> End With
>>>>
>>>> 'ADD Control ImageButton DOWN LIBEVE.
>>>> Dim myBtnLibEveDown As New ImageButton
>>>> With myBtnLibEveDown
>>>> .ImageUrl="/img/gen/down.gif"
>>>> .EnableViewState = ctype("False",Boolean)
>>>> .CausesValidation=ctype("False",Boolean)
>>>> .Attributes.Add("runat", "server")
>>>> .Attributes.Add("onMouseOver", "window.status=' '; return true;")
>>>> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveDown","patent.aspx")
>>>> .Id="myBtnLibEveDown"
>>>> .CommandArgument="LIBEVE DESC"
>>>> AddHandler myBtnLibEveDown.Command, New CommandEventHandler(AddressOf
>>>> myImgButtonSorting)
>>>> End With
>>>>
>>>> 'Add controls in e.Item.Cells(0)
>>>> e.Item.Cells(0).Controls.Add(myLibEve)
>>>> e.Item.Cells(0).Controls.Add(myBtnLibEveUp)
>>>> e.Item.Cells(0).Controls.Add(myBtnLibEveDown)
>>>>
>>>>
>>>> myLibEve.Dispose()
>>>> myLibEve=Nothing
>>>> myBtnLibEveUp.Dispose()
>>>> myBtnLibEveUp=Nothing
>>>> myBtnLibEveDown.Dispose()
>>>> myBtnLibEveDown=Nothing
>>>>
>>>> 'Texte de la Colonne Header : e.Item.Cells(1)
>>>> 'Label Colonne DATECH.
>>>> Dim myDatEch As New Label
>>>> With myDatEch
>>>> .Id="myDatEch"
>>>>
>>>> .Text=myLocalization.EasyResourceManager.myGetStri ng("myDatEch","patent.aspx")
>>>> .EnableViewState = ctype("False",Boolean)
>>>> .CssClass="txtOres2"
>>>> .Attributes.Add("runat", "server")
>>>> End With
>>>>
>>>> 'Ajout Control ImageButton UP DATECH.
>>>> Dim myBtnDatEchUp As New ImageButton
>>>> With myBtnDatEchUp
>>>> .ImageUrl="/img/gen/up.gif"
>>>> .EnableViewState = ctype("False",Boolean)
>>>> .CausesValidation=ctype("False",Boolean)
>>>> .Attributes.Add("runat", "server")
>>>> .Attributes.Add("onMouseOver", "window.status=' ';
>>>> return
>>>> true;")
>>>>
>>>> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveUp","patent.aspx")
>>>> .Id="myBtnDatEchUp"
>>>> .CommandArgument="DATECH ASC"
>>>> AddHandler myBtnDatEchUp.Command, New
>>>> CommandEventHandler(AddressOf
>>>> myImgButtonSorting)
>>>> End With
>>>>
>>>> 'Ajout Control ImageButton DOWN DATECH.
>>>> Dim myBtnDatEchDown As New ImageButton
>>>> With myBtnDatEchDown
>>>> .ImageUrl="/img/gen/down.gif"
>>>> .EnableViewState = ctype("False",Boolean)
>>>> .CausesValidation=ctype("False",Boolean)
>>>> .Attributes.Add("runat", "server")
>>>> .Attributes.Add("onMouseOver", "window.status=' ';
>>>> return
>>>> true;")
>>>>
>>>> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveDown","patent.aspx")
>>>> .Id="myBtnDatEchDown"
>>>> .CommandArgument="DATECH DESC"
>>>> AddHandler myBtnDatEchDown.Command, New
>>>> CommandEventHandler(AddressOf
>>>> myImgButtonSorting)
>>>> End With
>>>>
>>>> 'Ajout Effectif dans e.Item.Cells(0)
>>>> e.Item.Cells(1).Controls.Add(myDatEch)
>>>> e.Item.Cells(1).Controls.Add(myBtnDatEchUp)
>>>> e.Item.Cells(1).Controls.Add(myBtnDatEchDown)
>>>>
>>>> 'Libération Mémoire des trois Controls
>>>> myDatEch.Dispose()
>>>> myDatEch=Nothing
>>>> myBtnDatEchUp.Dispose()
>>>> myBtnDatEchUp=Nothing
>>>> myBtnDatEchDown.Dispose()
>>>> myBtnDatEchDown=Nothing
>>>>
>>>> 'Texte de la Colonne Header : e.Item.Cells(2)
>>>> 'Label Colonne NATURE.
>>>> Dim myNature As New Label
>>>> With myNature
>>>> .Id="myNature"
>>>>
>>>> .Text=myLocalization.EasyResourceManager.myGetStri ng("myNature","patent.aspx")
>>>> .EnableViewState = ctype("False",Boolean)
>>>> .CssClass="txtOres2"
>>>> .Attributes.Add("runat", "server")
>>>> End With
>>>>
>>>> 'Ajout Effectif dans e.Item.Cells(0)
>>>> e.Item.Cells(2).Controls.Add(myNature)
>>>>
>>>> 'Libération Mémoire des trois Controls
>>>> myNature.Dispose()
>>>> myNature=Nothing
>>>>
>>>> End If '.Item.ItemType = ListItemType.Header
>>>>
>>>> End Sub 'my009DataGrid_ItemCreated
>>>>
>>>>
>>>> part 2/ In .aspx file : My datagrid with OnItemCreated parameter
>>>>
>>>> <aspataGrid id="my009DataGrid"
>>>> runat="server"
>>>> FooterStyle-BorderWidth="0"
>>>> ShowFooter="False"
>>>> FooterStyle-BackColor="#F29168"
>>>> FooterStyle-ForeColor="#FFFFFF"
>>>> FooterStyle-BorderStyle= "None"
>>>> PagerStyle-Mode="NumericPages"
>>>> PageCount="1"
>>>> AutoGenerateColumns="False"
>>>> borderwidth="1"
>>>> bordercolor="black"
>>>> BorderStyle="Solid"
>>>> PagerStyle-VerticalAlign="top"
>>>> Cellpadding="1"
>>>> Cellspacing="0"
>>>> ShowHeader="True"
>>>> HeaderStyle-ForeColor="White"
>>>> HeaderStyle-Font-Bold="False"
>>>> HeaderStyle-HorizontalAlign="Center"
>>>> HeaderStyle-VerticalAlign="Middle"
>>>> AllowSorting="False"
>>>> AllowPaging="True"
>>>> OnPageIndexChanged="PageIndexChanged_OnClick"
>>>> OnItemCreated="my009DataGrid_ItemCreated"
>>>> PageSize="5"
>>>> width="100%"
>>>> HeaderStyle-BackColor="#93b0cc"
>>>> BackColor="#e5ecf2"
>>>> AlternatingItemStyle-BackColor="#e5ecf2"
>>>> PagerStyle-Backcolor="#93b0cc"
>>>> PagerStyle-Forecolor="Black"
>>>> PagerStyle-HorizontalAlign="Right"
>>>> PagerStyle-BorderStyle="Inset">
>>>>
>>>> <Columns>
>>>> <asp:BoundColumn DataField="libeve" ReadOnly="true">
>>>> <ItemStyle Font-Names="Times New Roman, Times, serif"
>>>> ForeColor="#003B6F"
>>>> Font-Size="10" horizontalalign="Left" VerticalAlign="Middle"
>>>> width="40%">
>>>> </ItemStyle>
>>>> </asp:BoundColumn>
>>>>
>>>> <asp:BoundColumn DataField="datech" DataFormatString="{0:d}"
>>>> ReadOnly="true">
>>>> <ItemStyle Font-Names="Times New Roman, Times, serif"
>>>> ForeColor="#003B6F"
>>>> Font-Size="10" horizontalalign="Center" VerticalAlign="Middle"
>>>> width="30%">
>>>> </ItemStyle>
>>>> </asp:BoundColumn>
>>>>
>>>> <asp:BoundColumn DataField="nature" ReadOnly="true"
>>>> HeaderText="Nature">
>>>> <ItemStyle Font-Names="Times New Roman, Times, serif"
>>>> ForeColor="#003B6F"
>>>> Font-Size="10" horizontalalign="Center" VerticalAlign="Middle"
>>>> width="30%">
>>>> </ItemStyle>
>>>> </asp:BoundColumn>
>>>> </Columns>
>>>>
>>>> </aspataGrid>
>>>>
>>>>
>>>>
>>>> thanks for your help
>>>
>>> I wonder why you are doing the dispose of the controls you create, I
>>> would
>>> think that one of the things that a dispose would do is remove all
>>> handlers.
>>>
>>> Hope this helps
>>> LS

>>

>
> Don't take this a gospel but it looks like in 1.1 the dispose did not
> remove the handler. That is only conjecture but I am glad that fixed the
> problem.
>
> LS



 
Reply With Quote
 
Fabrice
Guest
Posts: n/a
 
      06-27-2009

Sorry for my late,

Thanks for your help.
And have a nice week end.

fabrice

Lloyd Sheen wrote:

>
> "Fabrice" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hello Lloyd
>>
>> Your are right. I removed the "dispose" of the controls I have created.
>> And It works. I don't understand the difference of behavior between
>> framework 1.1 and 2.0.
>>
>> If your can explain me.
>>
>> Thanks
>> fabrice
>>
>>> think that one of the things that a dispose would do is remove all
>>> handlers.

>>
>> Lloyd Sheen wrote:
>>
>>>
>>> "Fabrice" <(E-Mail Removed)> wrote in message
>>> news:us%(E-Mail Removed)...
>>>> Sorry. This is my code :
>>>>
>>>> In my aspx file, I have a datagrid with the "OnItemCreated" parameter.
>>>> In my code behind (VB file), I have built all the buttons by code
>>>> (ImageButton).
>>>>
>>>> The Handler on the differents ImageButtons seems not be fire under .net
>>>> 2.0
>>>> It is ok under 1.1
>>>>
>>>> In my datagrid The parameter OnItemCreated is
>>>> OnItemCreated="my009DataGrid_ItemCreated"
>>>> (see part 2)
>>>>
>>>> part 1/ My code file in my .vb file
>>>> ------------------------------------
>>>>
>>>>
>>>> Sub my009DataGrid_ItemCreated(ByVal sender As Object, ByVal e As
>>>> System.Web.UI.WebControls.DataGridItemEventArgs)
>>>>
>>>> If e.Item.ItemType = ListItemType.Header Then
>>>>
>>>> 'ImageButton Header column : e.Item.Cells(0)
>>>>
>>>> Dim myLibEve As New Label
>>>> With myLibEve
>>>> .Id="myLibEve"
>>>>
>>>> .Text=myLocalization.EasyResourceManager.myGetStri ng("myLibEve","patent.aspx")
>>>> .EnableViewState = ctype("False",Boolean)
>>>> .CssClass="txtOres2"
>>>> .Attributes.Add("runat", "server")
>>>> End With
>>>>
>>>> 'ADD Control ImageButton UP LIBEVE.
>>>> Dim myBtnLibEveUp As New ImageButton
>>>> With myBtnLibEveUp
>>>> .ImageUrl="/img/gen/up.gif"
>>>> .EnableViewState = ctype("False",Boolean)
>>>> .CausesValidation=ctype("False",Boolean)
>>>> .Attributes.Add("runat", "server")
>>>> .Attributes.Add("onMouseOver", "window.status=' '; return true;")
>>>>
>>>> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveUp","patent.aspx")
>>>> .Id="myBtnLibEveUp"
>>>> .CommandArgument="LIBEVE ASC"
>>>> AddHandler myBtnLibEveUp.Command, New CommandEventHandler(AddressOf
>>>> myImgButtonSorting)
>>>> End With
>>>>
>>>> 'ADD Control ImageButton DOWN LIBEVE.
>>>> Dim myBtnLibEveDown As New ImageButton
>>>> With myBtnLibEveDown
>>>> .ImageUrl="/img/gen/down.gif"
>>>> .EnableViewState = ctype("False",Boolean)
>>>> .CausesValidation=ctype("False",Boolean)
>>>> .Attributes.Add("runat", "server")
>>>> .Attributes.Add("onMouseOver", "window.status=' '; return true;")
>>>> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveDown","patent.aspx")
>>>> .Id="myBtnLibEveDown"
>>>> .CommandArgument="LIBEVE DESC"
>>>> AddHandler myBtnLibEveDown.Command, New CommandEventHandler(AddressOf
>>>> myImgButtonSorting)
>>>> End With
>>>>
>>>> 'Add controls in e.Item.Cells(0)
>>>> e.Item.Cells(0).Controls.Add(myLibEve)
>>>> e.Item.Cells(0).Controls.Add(myBtnLibEveUp)
>>>> e.Item.Cells(0).Controls.Add(myBtnLibEveDown)
>>>>
>>>>
>>>> myLibEve.Dispose()
>>>> myLibEve=Nothing
>>>> myBtnLibEveUp.Dispose()
>>>> myBtnLibEveUp=Nothing
>>>> myBtnLibEveDown.Dispose()
>>>> myBtnLibEveDown=Nothing
>>>>
>>>> 'Texte de la Colonne Header : e.Item.Cells(1)
>>>> 'Label Colonne DATECH.
>>>> Dim myDatEch As New Label
>>>> With myDatEch
>>>> .Id="myDatEch"
>>>>
>>>> .Text=myLocalization.EasyResourceManager.myGetStri ng("myDatEch","patent.aspx")
>>>> .EnableViewState = ctype("False",Boolean)
>>>> .CssClass="txtOres2"
>>>> .Attributes.Add("runat", "server")
>>>> End With
>>>>
>>>> 'Ajout Control ImageButton UP DATECH.
>>>> Dim myBtnDatEchUp As New ImageButton
>>>> With myBtnDatEchUp
>>>> .ImageUrl="/img/gen/up.gif"
>>>> .EnableViewState = ctype("False",Boolean)
>>>> .CausesValidation=ctype("False",Boolean)
>>>> .Attributes.Add("runat", "server")
>>>> .Attributes.Add("onMouseOver", "window.status=' ';
>>>> return
>>>> true;")
>>>>
>>>> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveUp","patent.aspx")
>>>> .Id="myBtnDatEchUp"
>>>> .CommandArgument="DATECH ASC"
>>>> AddHandler myBtnDatEchUp.Command, New
>>>> CommandEventHandler(AddressOf
>>>> myImgButtonSorting)
>>>> End With
>>>>
>>>> 'Ajout Control ImageButton DOWN DATECH.
>>>> Dim myBtnDatEchDown As New ImageButton
>>>> With myBtnDatEchDown
>>>> .ImageUrl="/img/gen/down.gif"
>>>> .EnableViewState = ctype("False",Boolean)
>>>> .CausesValidation=ctype("False",Boolean)
>>>> .Attributes.Add("runat", "server")
>>>> .Attributes.Add("onMouseOver", "window.status=' ';
>>>> return
>>>> true;")
>>>>
>>>> .AlternateText=myLocalization.EasyResourceManager. myGetString("BtnLibEveDown","patent.aspx")
>>>> .Id="myBtnDatEchDown"
>>>> .CommandArgument="DATECH DESC"
>>>> AddHandler myBtnDatEchDown.Command, New
>>>> CommandEventHandler(AddressOf
>>>> myImgButtonSorting)
>>>> End With
>>>>
>>>> 'Ajout Effectif dans e.Item.Cells(0)
>>>> e.Item.Cells(1).Controls.Add(myDatEch)
>>>> e.Item.Cells(1).Controls.Add(myBtnDatEchUp)
>>>> e.Item.Cells(1).Controls.Add(myBtnDatEchDown)
>>>>
>>>> 'Libération Mémoire des trois Controls
>>>> myDatEch.Dispose()
>>>> myDatEch=Nothing
>>>> myBtnDatEchUp.Dispose()
>>>> myBtnDatEchUp=Nothing
>>>> myBtnDatEchDown.Dispose()
>>>> myBtnDatEchDown=Nothing
>>>>
>>>> 'Texte de la Colonne Header : e.Item.Cells(2)
>>>> 'Label Colonne NATURE.
>>>> Dim myNature As New Label
>>>> With myNature
>>>> .Id="myNature"
>>>>
>>>> .Text=myLocalization.EasyResourceManager.myGetStri ng("myNature","patent.aspx")
>>>> .EnableViewState = ctype("False",Boolean)
>>>> .CssClass="txtOres2"
>>>> .Attributes.Add("runat", "server")
>>>> End With
>>>>
>>>> 'Ajout Effectif dans e.Item.Cells(0)
>>>> e.Item.Cells(2).Controls.Add(myNature)
>>>>
>>>> 'Libération Mémoire des trois Controls
>>>> myNature.Dispose()
>>>> myNature=Nothing
>>>>
>>>> End If '.Item.ItemType = ListItemType.Header
>>>>
>>>> End Sub 'my009DataGrid_ItemCreated
>>>>
>>>>
>>>> part 2/ In .aspx file : My datagrid with OnItemCreated parameter
>>>>
>>>> <aspataGrid id="my009DataGrid"
>>>> runat="server"
>>>> FooterStyle-BorderWidth="0"
>>>> ShowFooter="False"
>>>> FooterStyle-BackColor="#F29168"
>>>> FooterStyle-ForeColor="#FFFFFF"
>>>> FooterStyle-BorderStyle= "None"
>>>> PagerStyle-Mode="NumericPages"
>>>> PageCount="1"
>>>> AutoGenerateColumns="False"
>>>> borderwidth="1"
>>>> bordercolor="black"
>>>> BorderStyle="Solid"
>>>> PagerStyle-VerticalAlign="top"
>>>> Cellpadding="1"
>>>> Cellspacing="0"
>>>> ShowHeader="True"
>>>> HeaderStyle-ForeColor="White"
>>>> HeaderStyle-Font-Bold="False"
>>>> HeaderStyle-HorizontalAlign="Center"
>>>> HeaderStyle-VerticalAlign="Middle"
>>>> AllowSorting="False"
>>>> AllowPaging="True"
>>>> OnPageIndexChanged="PageIndexChanged_OnClick"
>>>> OnItemCreated="my009DataGrid_ItemCreated"
>>>> PageSize="5"
>>>> width="100%"
>>>> HeaderStyle-BackColor="#93b0cc"
>>>> BackColor="#e5ecf2"
>>>> AlternatingItemStyle-BackColor="#e5ecf2"
>>>> PagerStyle-Backcolor="#93b0cc"
>>>> PagerStyle-Forecolor="Black"
>>>> PagerStyle-HorizontalAlign="Right"
>>>> PagerStyle-BorderStyle="Inset">
>>>>
>>>> <Columns>
>>>> <asp:BoundColumn DataField="libeve" ReadOnly="true">
>>>> <ItemStyle Font-Names="Times New Roman, Times, serif"
>>>> ForeColor="#003B6F"
>>>> Font-Size="10" horizontalalign="Left" VerticalAlign="Middle"
>>>> width="40%">
>>>> </ItemStyle>
>>>> </asp:BoundColumn>
>>>>
>>>> <asp:BoundColumn DataField="datech" DataFormatString="{0:d}"
>>>> ReadOnly="true">
>>>> <ItemStyle Font-Names="Times New Roman, Times, serif"
>>>> ForeColor="#003B6F"
>>>> Font-Size="10" horizontalalign="Center" VerticalAlign="Middle"
>>>> width="30%">
>>>> </ItemStyle>
>>>> </asp:BoundColumn>
>>>>
>>>> <asp:BoundColumn DataField="nature" ReadOnly="true"
>>>> HeaderText="Nature">
>>>> <ItemStyle Font-Names="Times New Roman, Times, serif"
>>>> ForeColor="#003B6F"
>>>> Font-Size="10" horizontalalign="Center" VerticalAlign="Middle"
>>>> width="30%">
>>>> </ItemStyle>
>>>> </asp:BoundColumn>
>>>> </Columns>
>>>>
>>>> </aspataGrid>
>>>>
>>>>
>>>>
>>>> thanks for your help
>>>
>>> I wonder why you are doing the dispose of the controls you create, I
>>> would
>>> think that one of the things that a dispose would do is remove all
>>> handlers.
>>>
>>> Hope this helps
>>> LS

>>

>
> Don't take this a gospel but it looks like in 1.1 the dispose did not
> remove
> the handler. That is only conjecture but I am glad that fixed the
> problem.
>
> LS


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
addhandler problem Slim ASP .Net 5 12-31-2006 06:37 PM
Addhandler problem HindenBug ASP .Net 1 08-30-2006 08:57 AM
AddHandler Problem =?Utf-8?B?REo=?= ASP .Net 4 11-02-2005 02:23 AM
AddHandler Problem. Urgent. Thank You Very Much. Shapper ASP .Net 1 10-29-2005 12:52 AM
Problem using AddHandler for dynamically created WebControls Nathan Sokalski ASP .Net 3 06-09-2005 02:33 AM



Advertisments