Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

Totally confused

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lloyd Sheen - 06 Mar 2008 02:46 GMT
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
Lloyd Sheen - 06 Mar 2008 02:55 GMT
> Ok I have a web control which is used to input search terms.  It works
> really well on one page.
[quoted text clipped - 16 lines]
>
> 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
Lloyd Sheen - 06 Mar 2008 03:00 GMT
>> Ok I have a web control which is used to input search terms.  It works
>> really well on one page.
[quoted text clipped - 38 lines]
>
> 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
Lloyd Sheen - 06 Mar 2008 04:10 GMT
>>> Ok I have a web control which is used to input search terms.  It works
>>> really well on one page.
[quoted text clipped - 47 lines]
>
> 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
John Kotuby - 28 Mar 2008 22:01 GMT
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...

>>>> Ok I have a web control which is used to input search terms.  It works
>>>> really well on one page.
[quoted text clipped - 176 lines]
>
> Lloyd Sheen
Lloyd Sheen - 29 Mar 2008 00:54 GMT
> Hi Lloyd,
> I'm assuming you found an answer to your problem already and just didn't
[quoted text clipped - 201 lines]
>>
>> Lloyd Sheen

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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.