84 users online (0 members and 84 guests)  

  Results 1 to 3 of 3


  1. HTML EMBED tag Problem    Forum: HTML Forum
    Replies: 2
  2. Replies: 2
  3. Replies: 0
  4. Replies: 4
  1. #1
    tpirkle's Avatar
    New User

    Join Date
    May 2005

    Unhappy How do I embed asp in html style attributes

    I'm trying to embed an asp.net function into the style height attribute of a table row. Here's what I'm trying to accomplish:

    The asp.net application on which I'm working currently uses HTML tables for formatting. While I realize that at some point we'll have to move away from that. It's necessary for now (no time for a rewrite).

    I have a printer-friendly page that has textboxes on it that I'd like to have grow dynamically based on the data within them. I've hidden the scrollbars using style="OVERFLOW: hidden". I've set the textbox borderstyle = none. As you can see, I'm trying to make the textbox appear as a label. The reason I'm not using a label is that the label control reformats and removes carriage returns and line feeds. I don't want my text reformatted. So, I'm trying to use a textbox.

    The textbox is embedded in a table row. It appears just as I want it to on the form, but it truncates some of the visible data. I wrote a VB script that calculates the number of rows in the textbox, increases the textbox.rows property accordingly, and returns the height in pixels that I want for the table row. Here's the function:

    <script language="visualbasic" runat="server">
    Function GetKeyTermsHeight() As String
    Dim sText As String
    Dim sTemp As String, iStart As Integer, iPos As Integer
    Dim iLineCount As Integer = 0, iTemp As Integer

    iStart = 1

    sText = txtKeyTerms.Text
    Do While True
    iPos = InStr(iStart, sText, vbCrLf)
    If iPos = 0 Then
    Exit Do
    End If

    iLineCount += 1
    iStart = iPos + 2

    If iLineCount = 0 Then iLineCount = 4
    txtKeyTerms.Rows = iLineCount

    iTemp = iLineCount * 16

    GetKeyTermsHeight = iTemp.ToString.Trim + "px"
    End Function

    Then, in the table row define, I'm trying to use the return value to set the row height as follows:

    <TD style="HEIGHT: GetKeyTermsHeight()" vAlign="middle" align="left" colSpan="4">

    The VS designer removes this every time. I have seen embedded functions in the attribute areas before, but can't find an example that is of this type. Can someone please offer assistance? Thanks!

  2. #2
    QuietDean's Avatar

    Join Date
    Oct 2000
    Bournemouth, UK

    Re: How do I embed asp in html style attributes

    I'm more an ASP than a .NET programmer, but have you tried:

    Rather than just the function call?
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    tpirkle's Avatar
    New User

    Join Date
    May 2005

    Re: How do I embed asp in html style attributes

    I finally got this to work. Here's what worked:
    <TD vAlign="middle" align="left" colSpan="4" style="HEIGHT: =GetKeyTermsHeight()" >

    The maddening thing is that this works, but if I change from the HTML tab to the Design tab, the IDE removes this code. I saved the code above in a comment in my code-behind module. I wish there was a way to stop that from happening. At least it works. Now, my text box autosizes and the table row expands to encompass it. Thanks for your response!

Tags for this Thread