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: Thu, 02 Aug 2007 20:35:03 -0000,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    unknown
          2    unknown


imagebutton clicking issues   
Hello,

I'm currently writing a webpage that lists photos dynamically.
Depending on what was selected in the page previous, these photos will
change.  What I'd like to do it to have the user click on a photo and
for that to pull up another page associated with that photo.  I can't
figure out how to make this happen, however.  Here's my html referring
to the imagebutton:

<asp:DataList ID="DataList1" runat="server">
<AlternatingItemStyle BackColor="#FFFFCC"></AlternatingItemStyle>
<ItemStyle BackColor="White"></ItemStyle>
<ItemTemplate>
<table border="0" cellpadding="2" cellspacing="0" class="Normal">
<tr>
<td>
<asp:Imagebutton ID="imgPhotoGallery"  ImageUrl='<%#
Container.DataItem %>' Runat="Server" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>

And I can't seem to get this to attach to any function in the
corresponding .aspx file.

I initially thought it would be this function:

Protected Sub DataList1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles DataList1.SelectedIndexChanged
        Dim sRedirect As String

        'go to edit page
        sRedirect = "Photo_Edit.aspx"
        Server.Transfer(sRedirect)
    End Sub

But that doesn't seem to work.

Please help!
Date:Thu, 02 Aug 2007 20:35:03 -0000   Author:  

Re: imagebutton clicking issues   
Hi vortiger,

You should add a handler to a method inside the ImageButton code this
way :

<asp:Imagebutton
   ID="imgPhotoGallery"
   ImageUrl='<%# Container.DataItem %>'
   Runat="Server"
   OnClick="imgPhotoGallery_Click"  />

Then create the corresponding method :

protected void imgPhotoGallery_Click(object sender,
ImageClickEventArgs e)
{
   // Handle the redirect / transfer here
}

You also have the option to replace your ImageButton with a simple
link containing an image, and embed the destination url directly into
the link :

// datalist definition...
<td>
       <a href="<%# RedirectAddress %>">
       <asp:Image
         ID="Image1"
         runat="server"
         ImageUrl='<%# Container.DataItem %>'/>
       </a>
</td>
// datalist definition...

You could set RedirectAddress through a column in your data source,
for instance. This solution avoids the round-trip to the server. Of
course, this is only possible if redirecting is the only thing your
button does.

HTH,

Michel

On 2 août, 22:35, vortiger...@yahoo.com wrote:

> Hello,
>
> I'm currently writing a webpage that lists photos dynamically.
> Depending on what was selected in the page previous, these photos will
> change.  What I'd like to do it to have the user click on a photo and
> for that to pull up another page associated with that photo.  I can't
> figure out how to make this happen, however.  Here's my html referring
> to the imagebutton:
>
> <asp:DataList ID="DataList1" runat="server">
> <AlternatingItemStyle BackColor="#FFFFCC"></AlternatingItemStyle>
> <ItemStyle BackColor="White"></ItemStyle>
> <ItemTemplate>
> <table border="0" cellpadding="2" cellspacing="0" class="Normal">
> <tr>
> <td>
> <asp:Imagebutton ID="imgPhotoGallery"  ImageUrl='<%#
> Container.DataItem %>' Runat="Server" />
> </td>
> </tr>
> </table>
> </ItemTemplate>
> </asp:DataList>
>
> And I can't seem to get this to attach to any function in the
> corresponding .aspx file.
>
> I initially thought it would be this function:
>
> Protected Sub DataList1_SelectedIndexChanged(ByVal sender As Object,
> ByVal e As System.EventArgs) Handles DataList1.SelectedIndexChanged
>         Dim sRedirect As String
>
>         'go to edit page
>         sRedirect = "Photo_Edit.aspx"
>         Server.Transfer(sRedirect)
>     End Sub
>
> But that doesn't seem to work.
>
> Please help!
Date:Sat, 04 Aug 2007 05:22:25 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


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