XSLT created UserControl gives 'not well formed' error

  • Thread starter Thread starter wtsnet
  • Start date Start date
W

wtsnet

I've got a usercontrol created on the fly using XSLT:

<%@ Control Language='vb' AutoEventWireup='false'
Codebehind='DynamicContent.ascx.vb'
Inherits='System.Web.UI.UserControl'
TargetSchema='http://schemas.microsoft.com/intellisense/ie
5' %>
<asp:Panel id="Panel_welcome" runat="server"
xmlns:asp="remove">
<asp:Image id="Image_welcome"
ImageUrl="PeopleOnBeach.jpg" runat="server"
class="picture_left">
</asp:Image>
</asp:Panel>

The <asp:Panel element gives a "The server tag is not
well formed" error. If you remove the xmlns:asp
attribute, it's OK. If you remove the runat="server"
attribute, the usercontrol loads OK (and the asp:Image
appears as an <IMG> correctly), but the <asp:Panel just
get's pushed straight through to the client, where the
browser ie6 ignores it.

Q1) Are <asp:Panel/> tags in the HTML output likely to
break some browsers?
Q2) Why does VS complain that 'The server tag is not well
formed?'

The whole surrounding problem is of trying to get data
held in XML to get translated to dynamically created web
server controls, but WITHOUT having to Parse and Add each
control in a code loop. (I'm just being bloody minded!)

Thanks!
Andy
 
Q1) Are said:
break some browsers?

If everything is correct, NO browser will see the <asp:Panel/> tag, and
should ignore
it if it was present. The ASP.Net system should translate this into
something the
current browser can understand.


By the way: interesting thing you are trying to do. Where exactly do you
generate
this code? Is it really translated by the ASP.Net system?


Hans Kesting
 
Thanks for your reply Hans,

my (secondary) problem is that The
<asp:Panel>...</asp:Panel> DOES make it though to the
HTML that appears on the client browser. (as the
runat='server' is missing, I assume the ASP.NET server
doesn't bother trying to translate it into a legal HTML
tag). But at least it doesn't throw up the 'not well
formed' error when the usercontrol is loaded
(programatically in the Page_Load event) - this is my
primary problem!

see:

http://www.gotdotnet.com/Community/MessageBoard/Thread.asp
x?id=165569&Page=1#166836

for more information on my trials so far!

The difficulty is getting ASP.NET to render the
<asp:control> tags before it sends the output off to the
client. You can use XSLT to transform the XML data into a
list of <asp:controls>, and then I think a previous
method was to add each control to the list in a loop (in
Page_Load e.g.) with Page.ParseControl (which turns the
<asp:control.... markup into a Control object which you
can add to the Page's Controls collection.

I wanted to do it with less code! (because I'm lazy, and
also for better encapsulation!) There's additional
problems of connecting dynamically added controls to the
code-behind if you want to play with the control's....
but I'm not at that point yet.

Downside with my method is that you've got to go via a
ascx file, so there's a read/write speed penalty. Might
be able to get Caching and auto event wireup going
though... Dunno!

What do you think?
 
Andy-
Could it be that you are giving the asp namespace a bogus definition;
i.e., "remove"? I have no idea what the proper string is, but I'm guessing
that your namespace definition makes the asp:Panel unrecognizable while the
runat = "server" implies that it *should* be something recognizable.

BTW, are you actually intending to send asp:Panel elements to a browser
(and if so, why?) I'm a bit of a newbie myself so this is just a guess.

Regards,
Bill
 
Hi Bill,

I agree with you that VS might need a proper valid
namespace definition - but what it would need I don't
know. Ideally I'd like to make the XSLT output elements
without any xmlns attributes, however I can't work out
how to do that. The closest I've got is to remove it from
children of a parent element (hence the Panel!). I don't
really *want* the panel...

Does that make any sense? Check out the link I posted to
the other thread for more background.

Thanks for your input though! My guesses are a) That
there's some sort of bug with usercontrols that doesn't
parse the <asp: elements properly ... my standard
paranoia reasoning! Or b) I'm not understanding how
namespaces work with usercontrols or XSLT transforms.
Which is why I've opened it up to the floor. Help!

I'm a bit new to ASP.NET (being a desktop coder), and am
never quite sure whether I'm doing things in a completely
stupid way!

Cheers,
Andy
 
Back
Top