Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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 April 22nd, 2004, 12:59 PM
Authorized User
 
Join Date: Jun 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default span tag with code behind

Hi,

I've just started using ASP.NET Code Behind files, and I have a span tag that I've turned into a server control by adding runat="server". I set the visibility on it in code behind, but I'm getting the error BC30002 Type 'Span' is not defined. In my code behind file I also imported htmlcontrols, but that didn't help.

I was using panels, but they generate html table output that causes problems with my page. I switched to span tags adding runat="server"
and wanted to set their visibility programmatically.

Can anyone clear me up here? I am a bit of a novice with code behind.


Thanks,

John
 
Old April 22nd, 2004, 01:49 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi John,

How does the code for your code behind look like? You should also add a declaration for the span tag in the Code Behind. In .NET, a <span> tag is known as a HtmlGenericControl, so you should add something like this tom your Code Behind:

protected System.Web.UI.HtmlControls.HtmlGenericControl testSpan;

or VB.NET

Protected testSpan As System.Web.UI.HtmlControls.HtmlGenericControl

Then in your Code Behind you can do something like this:

testSpan.InnerHtml = "<strong>Bla</strong>";

to assign the InnerHtml for the <span> tag.

Instead of a <span> element, you could also use a Literal control which renders no additional output, except for the string you assign to its Text property...

Does this help?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Save Tonight by Eagle-Eye Cherry (Track 1 from the album: Desireless)

 
Old April 22nd, 2004, 02:44 PM
Authorized User
 
Join Date: Jun 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think we just figured out the discrepancy:

In Netscape and Firefox/Mozilla, the asp:Panel does generate a table if you look at the source with the browser, while in IE it generates a div. We discontinued use of panel because we thought it autogenerated a table in the html output.

This just presents an additional step to account for in our style sheet.
Very interesting though...
 
Old April 22nd, 2004, 02:50 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yeah. Microsoft has an interesting idea of "down-level" browsers when it comes to rendering markup.
Even browsers that are more standards compliant than Internet Explorer (i.e. Firefox, Mozilla) are treated the same as old browsers like Netscape 4.....

Controls will adapt to the calling browser and render "appropriate" markup. However, I have a different definition of appropriate than Microsoft does... ;)


Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Still Life In Mobile Homes by Japan (Track 5 from the album: Tin Drum)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with <span> tag tclotworthy XSLT 2 February 18th, 2007 03:48 PM
Span Bug? interrupt HTML Code Clinic 4 June 20th, 2006 09:40 AM
Span tags not working Netscape apd8x Javascript 4 January 27th, 2005 06:11 AM
Referencing a "div" tag in a code behind file. cjo ASP.NET 1.0 and 1.1 Basics 2 December 23rd, 2003 01:53 PM
creating a form tag in code marciapz ASP.NET 1.0 and 1.1 Professional 6 August 1st, 2003 06:00 PM





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