Totally confused

L

Lloyd Sheen

Ok I have a web control which is used to input search terms. It works
really well on one page.

Now I need nearly the same functionallity on another page and I take the
pieces and move them to the new page (no web control). I have a button with
a click function which populates a repeater. On the first click of the
button it goes to the click handler and all is well. On the second click it
goes directly to the ItemCreated handler. Since the DataSource has not been
created of course this does not work.

Of course in the call stack there is nothing I can identify as to the reason
for the repeater to attempt the ItemCreated since it did not go thru my code
to get a new datasource.

I have tried all sorts of combinations of AutoEventWireup on the @Page
directive but nothing works on the second occurence.

Any ideas? If you want I can post code as well.

Lloyd Sheen
 
L

Lloyd Sheen

Lloyd Sheen said:
Ok I have a web control which is used to input search terms. It works
really well on one page.

Now I need nearly the same functionallity on another page and I take the
pieces and move them to the new page (no web control). I have a button
with a click function which populates a repeater. On the first click of
the button it goes to the click handler and all is well. On the second
click it goes directly to the ItemCreated handler. Since the DataSource
has not been created of course this does not work.

Of course in the call stack there is nothing I can identify as to the
reason for the repeater to attempt the ItemCreated since it did not go
thru my code to get a new datasource.

I have tried all sorts of combinations of AutoEventWireup on the @Page
directive but nothing works on the second occurence.

Any ideas? If you want I can post code as well.

Lloyd Sheen

Other detail:

Code in button click is:

Dim d As New DAL
Dim artistName As String
artistName = ArtistSearchText.Text

Me.Repeater3.DataSourceID = Nothing
Me.Repeater3.DataSource = d.GetAlbumList(artistName)
Me.Repeater3.DataBind()

ResultsUpdatePanel.Update()


If I comment out the DataBind on all subsequent button clicks it will go to
the click handler. Put the databind in and it no longer goes to the
handler.

Very confusing???

Lloyd Sheen
 
L

Lloyd Sheen

Lloyd Sheen said:
Other detail:

Code in button click is:

Dim d As New DAL
Dim artistName As String
artistName = ArtistSearchText.Text

Me.Repeater3.DataSourceID = Nothing
Me.Repeater3.DataSource = d.GetAlbumList(artistName)
Me.Repeater3.DataBind()

ResultsUpdatePanel.Update()


If I comment out the DataBind on all subsequent button clicks it will go
to the click handler. Put the databind in and it no longer goes to the
handler.

Very confusing???

Lloyd Sheen

And still more:

I added a page load handler (does nothing). On load of app it is called.
On first click it is called. After that who knows what is happening??

Certainly not me and certainly not ASP.NET.

Lloyd Sheen
 
L

Lloyd Sheen

Lloyd Sheen said:
And still more:

I added a page load handler (does nothing). On load of app it is called.
On first click it is called. After that who knows what is happening??

Certainly not me and certainly not ASP.NET.

Lloyd Sheen

Ok I have taken out all Ajax (toolkit) code and I now have a button which
when clicked will only work once.

Here is full code:

ASPX:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ShowSongs.aspx.vb"
Inherits="ShowSongs" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<table width="100%">
<tr>
<td >
<table>
<tr>
<td id="ArtistTD" >
<asp:Label ID="Label2" runat="server"
CssClass="SearchTitles" Text="Artist :"></asp:Label>
<asp:TextBox ID="ArtistSearchText" runat="server"
BackColor="#C0FFFF"></asp:TextBox>
<asp:ImageButton ID="SearchByArtist" runat="server"
ImageAlign="Middle"
ImageUrl="~/Images/find.ico"
OnClick="SearchByArtist_Click"
Width="32px" />
</td>
</tr>
</table>

</td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;<asp:Repeater ID="Repeater3" runat="server">
<HeaderTemplate>
<asp:Label ID="ArtistLabel" runat="server"
Text="Label"></asp:Label>
<br />
</HeaderTemplate>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" Height="24px"
Width="24px"
runat="server" />
<asp:Label ID="CDTitle" runat="server"
Text="Label"></asp:Label>
<br />
</ItemTemplate>
</asp:Repeater>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>


..VB codebehind

Option Strict On
Option Explicit On

Imports System.IO
Imports MusicSiteControls
Imports System.Collections.Generic

Partial Class ShowSongs
Inherits System.Web.UI.Page

Protected Sub SearchByArtist_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
Dim d As New DAL
Dim artistName As String
artistName = ArtistSearchText.Text
Me.Repeater3.DataSourceID = Nothing
Me.Repeater3.DataSource = d.GetAlbumList(artistName)
Me.Repeater3.DataBind()
End Sub

Protected Sub Repeater3_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
Repeater3.ItemCreated
Dim ArtistLabel As Label
Dim CDTit As Label
Dim ib As ImageButton
Dim ds As CD
Select Case e.Item.ItemType
Case ListItemType.Header
ArtistLabel = CType(e.Item.FindControl("ArtistLabel"),
Label)
ArtistLabel.Text = ArtistSearchText.Text
Case ListItemType.AlternatingItem, ListItemType.Item
ds = CType(e.Item.DataItem, CD)
ib = DirectCast(e.Item.FindControl("ImageButton1"),
ImageButton)
CDTit = CType(e.Item.FindControl("CDTitle"), Label)
CDTit.Text = ds.Name
Dim url As String
url = "~\DynamicImage.aspx?ImageFolder=" +
ds.FolderNumber.ToString + "&ImageText=" + "1"
ib.ImageUrl = url
End Select
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim i As Integer = 1
End Sub
End Class


HELP PLEASE!

This is just a page with a button and a repeater. How can this possibly go
so wrong??

Lloyd Sheen
 
J

John Kotuby

Hi Lloyd,
I'm assuming you found an answer to your problem already and just didn't
bother to post the solution, which I would be very interested in seeing.

My first thought on reading your posts was that the problems were deriving
from the use of an UpdatePanel. I've had some strange things happen with
UpdatePanels when the templates weren't defined such that they each contain
an entire Table (instead of just rows within a table).

Also the Page_Load should Not fire after the inital load of the page,
because the actual page persists in the browser during an asynch callback.

Also I was wondering if you were including the Button (actually an
ImageButton) as a child control in the update panel or at least defining it
as a Trigger for the panel.

But all those ideas went south when you said that you removed the "AJAX"
stuff.

I'm guessing you eventually re-wrote the page from scratch and got it to
finally work.

Cheers...
 
L

Lloyd Sheen

John Kotuby said:
Hi Lloyd,
I'm assuming you found an answer to your problem already and just didn't
bother to post the solution, which I would be very interested in seeing.

My first thought on reading your posts was that the problems were deriving
from the use of an UpdatePanel. I've had some strange things happen with
UpdatePanels when the templates weren't defined such that they each
contain an entire Table (instead of just rows within a table).

Also the Page_Load should Not fire after the inital load of the page,
because the actual page persists in the browser during an asynch callback.

Also I was wondering if you were including the Button (actually an
ImageButton) as a child control in the update panel or at least defining
it as a Trigger for the panel.

But all those ideas went south when you said that you removed the "AJAX"
stuff.

I'm guessing you eventually re-wrote the page from scratch and got it to
finally work.

Cheers...

I did post it. But what was wrong ended up being that I was handling the
ItemCreated rather than the ItemDataBound. I was creating the page by copy
pasting code but creating the events with IDE.

Still a very strange happening when something was wrong.

LS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top