473,394 Members | 1,751 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

AutoEventWireup Problem

I'm using the following code to verify weather the checkbox in the template
column of the datalist1 is checked
'
Sub Button1_Click(sender As Object, e As EventArgs)
cart.text="" Dim i As Integer For i = 0 To productlist.Controls.Count - 1
Dim item As DataListItem = productlist.Controls(i) If item.ItemType =
ListItemType.Item Or item.ItemType = ListItemType.AlternatingItem Then
Dim cb As System.Web.UI.WebControls.CheckBox =
item.FindControl("CheckBox1") 'Checkbox control in the datalist
Dim tb As System.Web.UI.WebControls.TextBox = item.FindControl("TB1")' Text
box control
Dim cod As System.Web.UI.WebControls.Label = item.FindControl("LB1")' Label
control in datalist
If cb.Checked = "True" Then cart.visible ="true"
cart.Text += "["+ cod.Text + "X " + tb.Text+ "]"
End If
end if
next
End Sub

' This is my datalist design
<asp:DataList id="productlist" runat="server" Height="42px"
RepeatColumns="3" RepeatDirection="Horizontal" HorizontalAlign="Center"
width="100%" DataKeyField="Code" GridLines="Both"
ItemStyle-HorizontalAlign="Center">
<ItemStyle horizontalalign="Center"></ItemStyle>
<ItemTemplate>
<asp:HyperLink id="HyperLink1" Target="_blank"
Runat="server" Text="Click to Enlarge"
ImageUrl='<%#string.format("images/th_{0}.jpg",container.dataitem("Code"))%>'
NavigateUrl='<%#string.format("maximage.aspx?SI={0 }",container.dataitem("Code"))%>'></asp:HyperLink>
<br />
<asp:Label id="LB1" text='<%#container.dataitem("Code")%>'
runat="server"></asp:Label>
<br />
<asp:CheckBox id="CheckBox1" Runat="server"
Checked="True"></asp:CheckBox>
Quantity:<asp:TextBox id="TB1" Runat="server"
Width="40px"></asp:TextBox>
<br />
</ItemTemplate>
</asp:DataList>

When I set AutoEvent Wireup ="False" then the page_load sub does not run
when i set it to "True" then the Button1_click sub does not run.
After the page load event occurs(autoeventwireup="false") i set
autoeventwireup="true" and refresh the page then every thing seems to work
fine. What do I do?
Thanx
Regards
Nitin
Nov 19 '05 #1
1 1980
Nitin wrote:
I'm using the following code to verify weather the checkbox in the template column of the datalist1 is checked
'
Sub Button1_Click(sender As Object, e As EventArgs)
cart.text="" Dim i As Integer For i = 0 To productlist.Controls.Count - 1 Dim item As DataListItem = productlist.Controls(i) If item.ItemType = ListItemType.Item Or item.ItemType = ListItemType.AlternatingItem Then Dim cb As System.Web.UI.WebControls.CheckBox =
item.FindControl("CheckBox1") 'Checkbox control in the datalist
Dim tb As System.Web.UI.WebControls.TextBox = item.FindControl("TB1")' Text box control
Dim cod As System.Web.UI.WebControls.Label = item.FindControl("LB1")' Label control in datalist
If cb.Checked = "True" Then cart.visible ="true"
cart.Text += "["+ cod.Text + "X " + tb.Text+ "]"
End If
end if
next
End Sub

' This is my datalist design
<asp:DataList id="productlist" runat="server" Height="42px"
RepeatColumns="3" RepeatDirection="Horizontal" HorizontalAlign="Center" width="100%" DataKeyField="Code" GridLines="Both"
ItemStyle-HorizontalAlign="Center">
<ItemStyle horizontalalign="Center"></ItemStyle>
<ItemTemplate>
<asp:HyperLink id="HyperLink1" Target="_blank"
Runat="server" Text="Click to Enlarge"
ImageUrl='<%#string.format("images/th_{0}.jpg",container.dataitem("Code"))%>'
NavigateUrl='<%#string.format("maximage.aspx?SI={0 }",container.dataitem("Code"))%>'></asp:HyperLink> <br />
<asp:Label id="LB1" text='<%#container.dataitem("Code")%>' runat="server"></asp:Label>
<br />
<asp:CheckBox id="CheckBox1" Runat="server"
Checked="True"></asp:CheckBox>
Quantity:<asp:TextBox id="TB1" Runat="server"
Width="40px"></asp:TextBox>
<br />
</ItemTemplate>
</asp:DataList>

When I set AutoEvent Wireup ="False" then the page_load sub does not run when i set it to "True" then the Button1_click sub does not run.
After the page load event occurs(autoeventwireup="false") i set
autoeventwireup="true" and refresh the page then every thing seems to work fine. What do I do?


It's probably a bug. Don't use AutoEventWireup, bind the event handler
by yourself.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Guy Lafleur | last post by:
I have a user control that builds a treeview dynamically in the Page_Load event. Also, I have the AutoEventWireup property set to true (i.e., <%@ Control AutoEventWireup="true" %>). Then, when I...
1
by: Quentin Huo | last post by:
Hi: This morning I found something wrong in my asp.net application: some pages and user controls didn't work well. it seems their Page_load method didnot work. For example if add a statement in...
1
by: prem | last post by:
Hi , Any one please give me the Usage with example for AutoEventWireUp PageDirective. Regards, Prem.
0
by: -Karl | last post by:
Ok.. I am totally stumped on this one. My site was workign great for awhile until I needed to have a Page_load event added to it. I added it and saw that it wasn't working. After ripping apart...
7
by: Danny Tuppeny | last post by:
Hi all, Looks like autoEventWireup defaults to true in 2.0. Kinda silly if you ask me, since the MS site says there's a performance penalty, and I can't imagine it's something used very often! ...
5
by: Juan T. Llibre | last post by:
OK, guys, usually I answer questions instead of asking them, but this thing has me scratching my head. Why is the default for AutoEventWireup different for C# and VB.NET ? In VS 2005, if I...
28
by: Tim_Mac | last post by:
hi, i'm new to .net 2.0, and am just starting to get to grips with the gridview. my page has autoEventWireUp set to true, which i gather is supposed to figure out which handlers to invoke when...
5
by: Carlo Marchesoni | last post by:
I read that autoeventwireup="false" doesn't cause Page_Load to fire automatically and trying it out with a simple page this can be confirmed easily. However, I have a page with...
0
by: ABCL | last post by:
Hi All I have UserControl with "AutoEventWireUp="true" Property, and I have drop this User Control on the Master Page MasterPage has: <%@ Master Language="C#" AutoEventWireup="true" ...../> ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.