How do i refer to "<META ..." in code?

P

Pealy

Hi. I'm trying to get one of the examples from ASP.NET 1.1 Insider
Solutions to work in asp.net and i'm getting stuck on using the META
tage to do a refresh.

I have the following in my HTML behind my aspx web form but the ID=..
is generating an error - "Could not find any attribute 'id' of element
'meta'."

<meta id="mtaRefresh" runat="server" />

If I have no ID how can I refer to the tag in my code? I want to do
the following:

Dim myMeta As HtmlControls.HtmlGenericControl
myMeta = Page.FindControl("mtaRefresh")
myMeta.Attributes.Add("http-equiv", "refresh")
myMeta.Attributes.Add("content", "0;url=" & sRefreshURL)

I've tried using name="mtaRefresh" but just get no object returned by
the FindControl.

Any suggestions are more than welcome but I'm quite a newcomer to asp.
 
G

Guest

Not sure why yours doesn't work, but try this: inside <head> add a "literal"
control with id= and runat= and set its text to your "<meta ...>".

Bill
 
N

Neil Smith

Thanks Saravana - I tried what you suggested and it doesn't cause any
errors but seems to have no effect whatsoever.

I added the lines to my Page_load (see below) but while the pnlWait is
shown okay there's no refresh and the LoadArtistTree() therefore never
called.

Any Ideas? I've tried it both inside and outside frames but this seems
to make no difference at all.

N.

Private Sub Page_Load(ByVal sender .....

If IsPostBack Then
' do nothing
Else

Dim sCustID As String = Request.QueryString("custID")
If sCustID > "" Then
LoadArtistTree()
Else
Dim sRefreshURL As String = Request.Url.ToString() & "?custID=1"
Response.AppendHeader("HTTP-EQUIV", "Refresh")
Response.AppendHeader("CONTENT", "2; URL=" & sRefreshURL)
pnlwait.Style("top") = 1
pnlwait.Visible = True

End If
End If


P.S - Replacing the response.appendheader lines with the following DOES
cause a refresh but that's not what I want to do.
 
N

Neil Smith

Hi Bill - apologies but I'm obviously a bit less advanced than I need to
be. I've no idea what a literal control is and as for adding a control
to a <head>??? If you could maybe elaborate I'd love to give it a try -
especially if there's a way of doing it from code as what I'm trying to
achieve is a 'pleas wait' type thing which shows the message while a big
tree is loading.

Thanks.
 
G

Guest

In this case, Saravana's suggestion is way better than mine, but here's what
I mean:

Your html by default has <head></head>, with a bunch of stuff in between.
Insert a control somewhere in there, e.g.
<HEAD>
... other stuff
<asp:literal id="litControl" runat="server"></asp:literal>
... other stuff
</HEAD>

Then, in Page Load, something like: litControl.Text = "<title>My Page
Title</title>"

This will dynamically change the title of your window. You could also insert
<meta> tags with your refresh stuff, etc.

hth,

Bill
 
N

Neil Smith

Hi Bill , thanks again,

Do you mean I can add stuff like this to a literal control? It doesn't
have to be a a <META> tag?

litControl.Attributes.Add("http-equiv", "refresh")
litControl.Attributes.Add("content", "0;url=" & sRefreshURL)

Neil.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top