asp response.write in asp.net
Hi Michael,
Thanks for that bit of advice. it is exactly the thing i was looking for.
I have now decided that maybe a should place a class betwwen
System.Web.UI.Page and the class in my code behind page.
The class in my code behing page will inherit from my middle tier class
which in turn inherits from System.Web.UI.Page.
In my new class I am placing the basehref and any other references to
outside sources
eg Javascript file and style sheets
that occur on every page.
cheers
Martin
Quote:
> I believe for things like that you can use asp.net literal control. So it
> would look like this in your aspx:
> <head>
> <asp:Literal id="MyBaseHref" runat="server"></asp:Literal>
> </head>
> And then in your code-behind on the page load do your logic:
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> If Page.IsPostBack Then Return
> ....
> declare and initialize sBaseHref here
> ....
> MyBaseHref.Text = "<base href='" & sBaseHref & "'>"
> End Sub
> > Hi,
> > I have been developing Classic ASP pages for a few years and have
just
> > decieded to check out the asp.net stuff.
> > Maybe I have misunderstood a concept here and I am hoping that somebody
> > could be put straight.
> > As I understand it the code behind page should contain all of the server
> > side logic and none of this server side logic should be contained in the
> > .aspx file.
> > so in all of my old .asp I had the following code in the <head></head>
> > section of the page to write out a different base href depending on the
> > server I was running on.
> > =============================================
> > dim sWebDomain ,sBaseHref
> > sWebDomain = Request.ServerVariables("SERVER_NAME")
> > if sWebDomain = "C3PO-2k" then
> > 'We are on the development machine
> > sBaseHref = "http://C3PO-2k/"
> > else if sWebDomain = "Mars" then
> > 'We are on the live machine
> > sBaseHref = "http://Mars/"
> > else if sWebDomain = "localhost"
> > 'we are on my local machine
> > sBaseHref = "http://Localhost/"
> > end if
> > response.write("<base href=' " & sBaseHref & "'>" & vbcrlf )
> > ================================================
> > anyway my question is how i would go about puting this in my new asp.net
> > project. (where does it belong aspx file or aspx.vb file)
> > I had write that code renderblocks should not be used in asp.net.
> > i tried using a script block in the aspx page which gave an error.
> > should i use console.writeline????
> > I am coding using visual studio.net 2002.
> > any help or pointers in the right direction are very much appreciated.
> > cheers
> > martin