Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 11th, 2005, 06:01 AM
Authorized User
 
Join Date: May 2005
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using <base href=""> with ASP.NET

Hi

I was trying to "simplify" the links on my website a little as at the moment I use all absolute links, so I thought that I would use the HTML tag <base href="htp://www.[mywebsite].co.uk">. I did this, then promptly changed all the links in my site from being absolute to relative. Everything appeared to be fine and I was happy that I hadn't made a back-up (oops!) until I noticed that my asp:linkbuttons and other postbacks no longer worked how I expected. What happened was that the page tried to post back to the specified base href, as opposed to the directory the page was in (using past-tense because I had to change everything back and upload again!), eg,

Base Url:
<base href="http://www.discover-the-bahamas.co.uk/" />

The relevant page was:
http://www.discover-the-bahamas.co.uk/ABA00/prices.aspx

But tried to post back instead to:
http:///www.discover-the-bahamas.co.uk/prices.aspx


I'm not sure if it makes a difference but the section of code which contains the linkbutton (and causes the postback) is all contained within a usercontrol (and controlbehind file for the user control), ie,

My [edited] prices.aspx page:
<%@ Page Language="VB" %>
<%@ Register TagPrefix="DTW" TagName="Prices" Src="../commonfiles/prices.ascx" %>
<!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>
    <title>Bahamas Holidays: Plan your Bahamas holiday from our extensive range of Bahamas accommodation and holiday options</title>
</head>
<body>
    <form runat="server">
        <DTW:PRICES id="pricePanel" runat="server"></DTW:PRICES>
    </form>
</body>
</html>


My [edited] usercontrol:
<%@ Control Language="VB" Inherits="DTW.PricesCodeBehind" Src="cbPrices.vb" %>
    <asp:DataList id="dlPrices" runat="server" DataKeyField="hr_Id" OnItemCommand="DataList_ItemCommand" OnItemDataBound="BindGrid" Width="95%">
        <itemtemplate>
            <asp:LinkButton id="btnDesc" runat="server" CommandName="select" CommandArgument='<%# Container.DataItem("hr_Id") %>'><h4 style="text-decoration:underline;"><%# DataBinder.Eval(Container.DataItem, "hr_Name") %></h4></asp:LinkButton>
        </itemtemplate>
    </asp:List>


My [edited] Code-behind:
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Text
Imports Microsoft.VisualBasic
Imports dataAccess

Namespace DTW

    Public Class PricesCodeBehind : Inherits UserControl

    Public data as New DataAccessComponent()
    Public dlPrices As DataList

    Sub Page_Load(Sender As Object, E As EventArgs)
        If Not IsPostBack Then
            dlPrices.DataSource = data.getRooms()
            dlPrices.DataBind()
        End If
    End Sub

    Sub DataList_ItemCommand(Sender As Object, E As DataListCommandEventArgs)
        Dim cmd As String = E.CommandSource.CommandName
        If cmd = "select" Then
            dlPrices.SelectedIndex = 0
        End If
        dlPrices.DataSource = data.getRooms(E.CommandSource.CommandArgument)
        dlPrices.DataBind()
        btnViewAll.Visible = True
    End Sub
End Class
End Namespace


As I've said, I'm now using all absolute paths again in my site, but I'd REALLY like to be able to use some kind of base url that I can specify once in the page (or web.config or at application level?) so that I don't have to use it in every single link. Does anyone know of a way that I can do this which won't adversely effect my postbacks?

Thanks so much.

Shane





Similar Threads
Thread Thread Starter Forum Replies Last Post
Including XSL in an <a href> graywoodhouse XSLT 2 November 12th, 2004 06:08 AM
<href> causing problems mahulda ASP.NET 1.0 and 1.1 Basics 5 July 15th, 2004 12:15 PM
a problem in book<<beginning asp.net using vb>> luoware ASP.NET 1.0 and 1.1 Basics 3 December 8th, 2003 09:32 PM
<<ASP.NET Security>>,download files in chapter 8 alaix All Other Wrox Books 1 July 24th, 2003 10:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.