Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 July 13th, 2006, 11:25 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default a block of html code

Hi,
In asp classic we could do sth like this to display a block of html code according to a condition statement :
if strName=test then
<table class=Err align=center>
    <tr>
    <td class=font1><%=InvalidUID%></td>
    </tr>
</table>
<%else%>
eee
<%end if%>

Now How can I do sth in an aspx page.??
it may seem simple when using server side controls
but I need to put static html like a table in my code

 
Old July 13th, 2006, 12:58 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You will find that a server side control, like a label for instance, renders as a <span></span> tag.

There are (at least) 2 solutions to your answer.

1) Create a panel on your aspx page and name it whatever. In your code behind you can do something like this:

         If strName = "test" then
              Dim tbl as table
              Dim tc as tablecell
              Dim tr as tablerow

              tr = new tablerow
              tc = new tablecell
              tc.text = "Whatever"
              tr.cells.add(tc)
              table.rows.add(tr)
              panel1.controls.add(table)
         Else
             [do something]
         End if

If your condition is met a table will be created at runtime, added to the panel and then displayed (and rendered in HTML) as a table.

The old way of doing things (namely code inline with HTML) still works. But what you ahve to do is on your backend you have to define your variable strName and invalidUID with a global scope and give it Public access so:

Public strName as string
Public InvalidUID as string

Private Sub Page_Load.......
End Sub

Then on your front end you do everything just as you have displayed in your post.

"The one language all programmers understand is profanity."
 
Old July 14th, 2006, 12:48 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks.good solution






Similar Threads
Thread Thread Starter Forum Replies Last Post
Code Render Block to hide table rdove84 ASP.NET 1.0 and 1.1 Basics 5 February 16th, 2007 05:57 PM
Jump to a code block tlwms BOOK: Professional Assembly Language 0 July 16th, 2006 10:31 AM
HTML block in Text field ndisdabest HTML Code Clinic 2 August 16th, 2005 02:25 PM
What is wrong in my HTML-code.....?????? Burton HTML Code Clinic 11 October 13th, 2004 08:16 AM





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