Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image based Link not firing event....

Status
Not open for further replies.

JAG14

Programmer
Sep 26, 2003
469
GB
Hi Everyone,

Got an issue with an ASP.NET 2.0 Web application in that from the 16th september, a link isn't firing the event that redirects the user to another page.

Am I missing something common that that can cause this as the actual code HASN'T BEEN CHANGED in 2 years!
(Know this from the modified flags in my SC program and Windows is reporting same date)

Basically, the a user requests a price based on date input, no. of nights and no. of people. The form then posts back for the price, showing a "Book Now" button if the vacation is bookable online (another variable.)

This process is working fine, except when the form comes back from it's postback and the button appears, the button will only link to the last page that was visited by clicking a button, normally forcing the browser to show a "Cannot display the webpage" equivalent.

Strangely, after you click [Back] on the browser, you can then click another button "Enquire Now" on the page that is meant to do something else entirely and that will take you to the target of the "Book Now" button.

This is an inherited and badly annotated/variable-ized project, but as I said, this was working pre-16th september and the code for this page hasn't changed...

A redacted copy of the codebehind for dlDetail (the container for the button) and the ItemCommand from dlDetail which contains the code that isn't firing.
Code:
  Protected Sub dlDetail_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlDetail.ItemDataBound


    'gets a reference to the current datarow
    Dim d As DataRow = CType(e.Item.DataItem, DataRowView).Row
    u.t("processing idPlaceToStay: " & d("IDPlaceToStay"))

    Dim lb As Label
    Dim hyp As HyperLink
    Dim lit As Literal
    Dim pnl As Panel
    Dim img As Web.UI.WebControls.Image
    Dim lang As String = u.getlang
    Dim x As New search(search.identifiers.accomm_search) 'a reference to the current search

    '************
    'property general info and pricing display
    lit = CType(e.Item.FindControl("litLocation"), Literal)
    lit.Text = d("LocationName")

    lb = CType(e.Item.FindControl("lblLocation"), Label)
    If d("DestinationName") <> d("CountryDesc") Then
      lb.Text = d("locationname") & "<br />" & urlrewriter.makeinfolink(d("MapzoneDesc")) & ", " & urlrewriter.makeinfolink(d("DestinationName")) & ", " & urlrewriter.makeinfolink(d("CountryDesc"))
    Else
      lb.Text = d("locationname") & "<br />" & urlrewriter.makeinfolink(d("MapzoneDesc")) & ", " & urlrewriter.makeinfolink(d("DestinationName"))
    End If

    lb = CType(e.Item.FindControl("lblPlaceToStayRef1"), Label)
    lb.Text = d("PlaceToStayRef")

    lb = CType(e.Item.FindControl("lblPlaceToStayRef2"), Label)
    lb.Text = d("PlaceToStayRef")

    lb = CType(e.Item.FindControl("lblIdaccomm"), Label)
    lb.Text = d("IDPlaceToStay")

    lb = CType(e.Item.FindControl("lblPrice"), Label)
    lb.Text = d("strCostDisplay").ToString
    If u.nz(d("bPriceContainsSpecial"), False) = True Then
      lb.Text += "<br /><span style=""color: #CC3300;"">Reduced Offer Price</span>"
    End If

    Dim poolpnl As Panel = CType(e.Item.FindControl("pnlPool"), Panel)
    lit = CType(e.Item.FindControl("lblPool"), Literal)
    If Trim(d("strPoolDisplay").ToString) <> "" Then
      lit.Text = d("strPoolDisplay").ToString
      poolpnl.Visible = True
    Else
      poolpnl.Visible = False
    End If

    lb = CType(e.Item.FindControl("lblSleeps"), Label)
    lb.Text = u.nz(d("iSleepsMax"), "")

    lb = CType(e.Item.FindControl("lblSleepsAdults"), Label)
    If CInt(d("Children")) > 0 Then
      Dim pnlSleepsAdCh As Panel = CType(e.Item.FindControl("pnlSleepsAdCh"), Panel)
      pnlSleepsAdCh.Visible = True
      lb = CType(e.Item.FindControl("lblSleepsAdults"), Label)
      lb.Text = d("Adults")
      lb = CType(e.Item.FindControl("lblSleepsChildren"), Label)
      lb.Text = d("Children")
    End If

    Dim imgbt As ImageButton = CType(e.Item.FindControl("btnReserveNow"), ImageButton)
    If d("confirmationlevel") <= 20 And x.availability And x.fromdate.AddDays(-3) > DateTime.Now And u.nz(d("totalcost"), 0) > 0 Then
      imgbt.Visible = True
      imgbt.ImageUrl = "/images/lang/" & u.getlanglocale & "/booknow.gif"
      imgbt.AlternateText = Resources.words.Book_Now
    ElseIf d("confirmationlevel") = 30 And x.availability And x.fromdate.AddDays(-3) > DateTime.Now And u.nz(d("totalcost"), 0) > 0 Then
      imgbt.Visible = True
      imgbt.ImageUrl = "" ' "/images/lang/" & u.getlanglocale & "/reservenow.gif"
      imgbt.AlternateText = Resources.words.Reserve_Now
    Else
      imgbt.Visible = False
    End If

    '************
    'villa prices
    pnl = CType(e.Item.FindControl("pnlVillaPrice"), Panel)
    If d("strCostDisplay") Is System.DBNull.Value Then pnl.Visible = False
    Dim vp As villas_villaprice
    vp = CType(e.Item.FindControl("VillaPrice"), villas_villaprice)
    vp.setidaccomm = d("idPlaceToStay")


    '************
    'shortlist hyperlinks
    hyp = CType(e.Item.FindControl("hypAddShort"), HyperLink)
    img = CType(e.Item.FindControl("imgInShort"), WebControls.Image)

    Dim shortlist As New shortlist

    Dim backurl As String = ""
    If wu.utils.rf("URL") <> "" Then
      backurl = "&URL=" & wu.utils.rf("URL")
    End If

    If shortlist.IsInShortlist(dlDetail.DataKeys(e.Item.ItemIndex)) Then 'if the current idPlaceToStay is in the shortlist
      hyp.NavigateUrl = "/villas/villas.aspx?shtlist=remove&md=1&idaccomm=" & d("idPlaceToStay") & "&accommref=" & HttpContext.Current.Server.UrlPathEncode(d("PlaceToStayref")) & "&ci = " & lblCurrentIndex.Text & backurl
      hyp.Text = Resources.words.Remove_from_Shortlist
      hyp.ToolTip = Resources.words.Remove_from_Shortlist & ": " & d("PlaceToStayRef") & ", " & d("DestinationName") & " " & Resources.words.villa_upper
      hyp.ImageUrl = "/images/lang/" & u.getlanglocale & "/remsht.gif"
      img.ImageUrl = "/images/widgets/selected.gif"
      'hyp.Attributes.Add("rel", "nofollow")
      img.Visible = True
      img.AlternateText = Resources.words.Shortlist
    Else 'is QWI site - no shortlist enquiries
      img.Visible = False
      hyp.Visible = False
    End If

    '************
    'display the distances for this property
    Dim strdistances As String = getdistances(d("IDPlaceToStay"))
    lit = CType(e.Item.FindControl("litDistances"), Literal)
    If strdistances <> "" Then
      lit.Text = "<h2>" & Resources.words.Property_Location & "</h2>" & strdistances
    Else
      lit.Visible = False
    End If


    Dim ajaxtabcontainer As AjaxControlToolkit.TabContainer
    ajaxtabcontainer = CType(e.Item.FindControl("TabContainer1"), AjaxControlToolkit.TabContainer)
    Dim ajaxtab As AjaxControlToolkit.TabPanel


    'conditions  policy
    '************
    ajaxtab = e.Item.FindControl("TabContainer1").FindControl("pnlCancellations")
    Dim strcancellations As String = u.nz(d("summarytermsconditions"), "")
    Dim cancellationstable As String = "<span style=""font-size:11px"">" & strcancellations & "</span>"
    'pricingTermsConditions.createsummaryconditions(d("idPlaceToStay"), u.getcurrency)
    If strcancellations <> "" Then
      ajaxtab.HeaderText = Resources.words.Summary_Conditions
      lit = e.Item.FindControl("TabContainer1").FindControl("pnlCancellations").FindControl("pnlCancellationsLiteral")
      lit.Text = cancellationstable

    Else
      ajaxtab.Visible = False
      ajaxtab.HeaderText = ""
    End If

    Dim ph As New PlaceHolder

    '************
    'availability display
    Dim currency As Integer = u.getcurrency 'get the currency for the site

    ajaxtab = e.Item.FindControl("TabContainer1").FindControl("pnlPrices")
    ajaxtab.HeaderText = Resources.words.Availability
    img = e.Item.FindControl("TabContainer1").FindControl("pnlPrices").FindControl("pnlAvailabilityImage")
    img.ImageUrl = "/villas/availjpg.aspx?idaccomm=" & d("IDPlaceToStay") & "&formonths=18&fromdate=" & Now.ToString("yyyy-MM-dd")
    img.AlternateText = Resources.words.Availability & ": " & d("PlaceToStayRef") & ", " & d("DestinationName") & " " & Resources.words.villa_upper
    img.ToolTip = Resources.words.Availability & ": " & d("PlaceToStayRef") & ", " & d("DestinationName") & " " & Resources.words.villa_upper

    '************
    'pricing display
    ajaxtab = e.Item.FindControl("TabContainer1").FindControl("pnlPrices")
    ajaxtab.HeaderText = Resources.words.Price_and_Availability
    ph = e.Item.FindControl("TabContainer1").FindControl("pnlPrices").FindControl("phPricesTable")
    ph.Controls.Add(properties.getpricetable(CInt(d("IDPlaceToStay")), 12, currency, CInt(d("adults")) + CInt(d("children")), , "80%"))


  End Sub

  Protected Sub dlDetail_ItemCommand(ByVal source As Object, ByVal e As     System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlDetail.ItemCommand
    'get the current datarow by accessing the saved (in session) datatable
    Dim dt As DataTable

    dt = CType(Session("holidaylister_datatable_mode1"), DataTable)

    'pass the key defined for the datalist to the Find
    Dim d As DataRow = dt.Rows.Find(dlDetail.DataKeys(e.Item.ItemIndex))
    u.t("itemindex:" & e.Item.ItemIndex.ToString)
    Select Case e.CommandName
      Case "AddToShortlist"
        Dim s As New shortlist
        s.AddToShortlist(d("idPlaceToStay"), d("PlaceToStayref"))
      Case "RemoveFromShortlist"
        Dim s As New shortlist
        s.RemoveFromShortList(d("idPlaceToStay"))
      Case "ReserveNow"
         doreservation(d("idPlaceToStay"), d("idcomplex"))
      Case "AddtoQuote"
        Dim quote As New currentquote
        quote.addtoquote(dt, "idPlaceToStay=" & d("idPlaceToStay"))
    End Select
  End Sub

Any help or suggestions would be GREATLY appreciated guys and girls.. Thanks in advance.

yosherrs.gif

[tt]'Very funny, Scotty... Now Beam down my clothes.'[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top