ASP.NET label control not wrapping text in non-IE browsers

Discussion in 'ASP .Net' started by Mike Casey, Dec 17, 2003.

  1. Mike Casey

    Mike Casey Guest

    Hello all,
    I have ASP.NET label controls tied to a datasource (so
    text will vary in length depending on the record). In IE
    everything looks great--text is wrapped if needed. In
    Netscape and Opera, the text extends horizontally and does
    not wrap.

    Any ideas would be most appreciated!

    Thanks,
    Mike
    Mike Casey, Dec 17, 2003
    #1
    1. Advertising

  2. Mike Casey

    Scott M. Guest

    Have you set the width of the label? Labels render as SPAN tags in the
    resulting HTML and if you have specified a width, that will appear as an
    inline style attribute of the SPAN tag. If this does not work in a browser,
    then that browser does not support CSS.


    "Mike Casey" <> wrote in message
    news:01db01c3c4e3$fbf91050$...
    > Hello all,
    > I have ASP.NET label controls tied to a datasource (so
    > text will vary in length depending on the record). In IE
    > everything looks great--text is wrapped if needed. In
    > Netscape and Opera, the text extends horizontally and does
    > not wrap.
    >
    > Any ideas would be most appreciated!
    >
    > Thanks,
    > Mike
    Scott M., Dec 17, 2003
    #2
    1. Advertising

  3. Mike Casey

    Mike Casey Guest

    Thanks! I specify the width and height directly in the
    HTML view of the page. I've noticed that making this
    change within the "Style" parameters (HEIGHT: 42px; WIDTH:
    100px;) works temporarily. However after recompiling the
    application, the height and width attributes appear again
    outside the Style tag (I assume this is because they are
    set in the property window / Design view of the server
    control).

    I'm thinking of removing them from the properties window
    and also resorting to a pure HTML control rather than a
    server-based Web control, but I'm struggling with why I
    have to do this.

    Thanks again!
    Mike
    >-----Original Message-----
    >Have you set the width of the label? Labels render as

    SPAN tags in the
    >resulting HTML and if you have specified a width, that

    will appear as an
    >inline style attribute of the SPAN tag. If this does not

    work in a browser,
    >then that browser does not support CSS.
    >
    >
    >"Mike Casey" <> wrote

    in message
    >news:01db01c3c4e3$fbf91050$...
    >> Hello all,
    >> I have ASP.NET label controls tied to a datasource (so
    >> text will vary in length depending on the record). In

    IE
    >> everything looks great--text is wrapped if needed. In
    >> Netscape and Opera, the text extends horizontally and

    does
    >> not wrap.
    >>
    >> Any ideas would be most appreciated!
    >>
    >> Thanks,
    >> Mike

    >
    >
    >.
    >
    Mike Casey, Dec 18, 2003
    #3
  4. Mike Casey

    Scott M. Guest

    "Mike Casey" <> wrote in message
    news:07d701c3c568$5bef0e90$...
    > Thanks! I specify the width and height directly in the
    > HTML view of the page. I've noticed that making this
    > change within the "Style" parameters (HEIGHT: 42px; WIDTH:
    > 100px;) works temporarily. However after recompiling the
    > application, the height and width attributes appear again
    > outside the Style tag (I assume this is because they are
    > set in the property window / Design view of the server
    > control).
    >


    Not sure what you mean here. You can easily just set the width of the label
    in the properties window while the page is open in design view. There's no
    need to code it yourself in the HTML view.


    > I'm thinking of removing them from the properties window
    > and also resorting to a pure HTML control rather than a
    > server-based Web control, but I'm struggling with why I
    > have to do this.
    >
    > Thanks again!
    > Mike
    > >-----Original Message-----
    > >Have you set the width of the label? Labels render as

    > SPAN tags in the
    > >resulting HTML and if you have specified a width, that

    > will appear as an
    > >inline style attribute of the SPAN tag. If this does not

    > work in a browser,
    > >then that browser does not support CSS.
    > >
    > >
    > >"Mike Casey" <> wrote

    > in message
    > >news:01db01c3c4e3$fbf91050$...
    > >> Hello all,
    > >> I have ASP.NET label controls tied to a datasource (so
    > >> text will vary in length depending on the record). In

    > IE
    > >> everything looks great--text is wrapped if needed. In
    > >> Netscape and Opera, the text extends horizontally and

    > does
    > >> not wrap.
    > >>
    > >> Any ideas would be most appreciated!
    > >>
    > >> Thanks,
    > >> Mike

    > >
    > >
    > >.
    > >
    Scott M., Dec 18, 2003
    #4
  5. Mike Casey

    Mike Casey Guest

    I'm thinking there might be a reason in this case. If you
    make changes in the properties window, the Width and
    Height parameters appear by themselves in HTML, outside of
    the Style tag. I'm thinking that some browsers might not
    recognize these values unless they are within the Style
    tag. Maybe?
    >-----Original Message-----
    >
    >"Mike Casey" <> wrote

    in message
    >news:07d701c3c568$5bef0e90$...
    >> Thanks! I specify the width and height directly in the
    >> HTML view of the page. I've noticed that making this
    >> change within the "Style" parameters (HEIGHT: 42px;

    WIDTH:
    >> 100px;) works temporarily. However after recompiling

    the
    >> application, the height and width attributes appear

    again
    >> outside the Style tag (I assume this is because they are
    >> set in the property window / Design view of the server
    >> control).
    >>

    >
    >Not sure what you mean here. You can easily just set the

    width of the label
    >in the properties window while the page is open in design

    view. There's no
    >need to code it yourself in the HTML view.
    >
    >
    >> I'm thinking of removing them from the properties window
    >> and also resorting to a pure HTML control rather than a
    >> server-based Web control, but I'm struggling with why I
    >> have to do this.
    >>
    >> Thanks again!
    >> Mike
    >> >-----Original Message-----
    >> >Have you set the width of the label? Labels render as

    >> SPAN tags in the
    >> >resulting HTML and if you have specified a width, that

    >> will appear as an
    >> >inline style attribute of the SPAN tag. If this does

    not
    >> work in a browser,
    >> >then that browser does not support CSS.
    >> >
    >> >
    >> >"Mike Casey" <>

    wrote
    >> in message
    >> >news:01db01c3c4e3$fbf91050$...
    >> >> Hello all,
    >> >> I have ASP.NET label controls tied to a datasource

    (so
    >> >> text will vary in length depending on the record).

    In
    >> IE
    >> >> everything looks great--text is wrapped if needed.

    In
    >> >> Netscape and Opera, the text extends horizontally and

    >> does
    >> >> not wrap.
    >> >>
    >> >> Any ideas would be most appreciated!
    >> >>
    >> >> Thanks,
    >> >> Mike
    >> >
    >> >
    >> >.
    >> >

    >
    >
    >.
    >
    Mike Casey, Dec 19, 2003
    #5
  6. Mike Casey

    Scott M. Guest

    I'm not sure you are following my instructions or you may have a problem
    with your VS installation.

    If I put a label on a webform and then change its height and width
    properties in the property window and then run the project, I get the
    following HTML sent to my client:

    <span id="Label1" style="height:75px;width:100px">Label</span>

    Note that the height and width are attribute values for the style attribute
    of the span tag. This is the correct behavior. I'm not sure what you mean
    by the parameters appearing by themselves in HTML outside of the style tag,
    but if you are not getting the same results as I'm showing above, then
    something is wrong.


    "Mike Casey" <> wrote in message
    news:085101c3c635$2e826650$...
    > I'm thinking there might be a reason in this case. If you
    > make changes in the properties window, the Width and
    > Height parameters appear by themselves in HTML, outside of
    > the Style tag. I'm thinking that some browsers might not
    > recognize these values unless they are within the Style
    > tag. Maybe?
    > >-----Original Message-----
    > >
    > >"Mike Casey" <> wrote

    > in message
    > >news:07d701c3c568$5bef0e90$...
    > >> Thanks! I specify the width and height directly in the
    > >> HTML view of the page. I've noticed that making this
    > >> change within the "Style" parameters (HEIGHT: 42px;

    > WIDTH:
    > >> 100px;) works temporarily. However after recompiling

    > the
    > >> application, the height and width attributes appear

    > again
    > >> outside the Style tag (I assume this is because they are
    > >> set in the property window / Design view of the server
    > >> control).
    > >>

    > >
    > >Not sure what you mean here. You can easily just set the

    > width of the label
    > >in the properties window while the page is open in design

    > view. There's no
    > >need to code it yourself in the HTML view.
    > >
    > >
    > >> I'm thinking of removing them from the properties window
    > >> and also resorting to a pure HTML control rather than a
    > >> server-based Web control, but I'm struggling with why I
    > >> have to do this.
    > >>
    > >> Thanks again!
    > >> Mike
    > >> >-----Original Message-----
    > >> >Have you set the width of the label? Labels render as
    > >> SPAN tags in the
    > >> >resulting HTML and if you have specified a width, that
    > >> will appear as an
    > >> >inline style attribute of the SPAN tag. If this does

    > not
    > >> work in a browser,
    > >> >then that browser does not support CSS.
    > >> >
    > >> >
    > >> >"Mike Casey" <>

    > wrote
    > >> in message
    > >> >news:01db01c3c4e3$fbf91050$...
    > >> >> Hello all,
    > >> >> I have ASP.NET label controls tied to a datasource

    > (so
    > >> >> text will vary in length depending on the record).

    > In
    > >> IE
    > >> >> everything looks great--text is wrapped if needed.

    > In
    > >> >> Netscape and Opera, the text extends horizontally and
    > >> does
    > >> >> not wrap.
    > >> >>
    > >> >> Any ideas would be most appreciated!
    > >> >>
    > >> >> Thanks,
    > >> >> Mike
    > >> >
    > >> >
    > >> >.
    > >> >

    > >
    > >
    > >.
    > >
    Scott M., Dec 19, 2003
    #6
  7. Mike Casey

    Mike Casey Guest

    AH...actually that is the HTML label you are adding,
    right? If I add the Web Forms Label control, the tags are
    handled differently...
    >-----Original Message-----
    >I'm not sure you are following my instructions or you may

    have a problem
    >with your VS installation.
    >
    >If I put a label on a webform and then change its height

    and width
    >properties in the property window and then run the

    project, I get the
    >following HTML sent to my client:
    >
    ><span id="Label1"

    style="height:75px;width:100px">Label</span>
    >
    >Note that the height and width are attribute values for

    the style attribute
    >of the span tag. This is the correct behavior. I'm not

    sure what you mean
    >by the parameters appearing by themselves in HTML outside

    of the style tag,
    >but if you are not getting the same results as I'm

    showing above, then
    >something is wrong.
    >
    >
    >"Mike Casey" <> wrote

    in message
    >news:085101c3c635$2e826650$...
    >> I'm thinking there might be a reason in this case. If

    you
    >> make changes in the properties window, the Width and
    >> Height parameters appear by themselves in HTML, outside

    of
    >> the Style tag. I'm thinking that some browsers might

    not
    >> recognize these values unless they are within the Style
    >> tag. Maybe?
    >> >-----Original Message-----
    >> >
    >> >"Mike Casey" <>

    wrote
    >> in message
    >> >news:07d701c3c568$5bef0e90$...
    >> >> Thanks! I specify the width and height directly in

    the
    >> >> HTML view of the page. I've noticed that making this
    >> >> change within the "Style" parameters (HEIGHT: 42px;

    >> WIDTH:
    >> >> 100px;) works temporarily. However after recompiling

    >> the
    >> >> application, the height and width attributes appear

    >> again
    >> >> outside the Style tag (I assume this is because they

    are
    >> >> set in the property window / Design view of the

    server
    >> >> control).
    >> >>
    >> >
    >> >Not sure what you mean here. You can easily just set

    the
    >> width of the label
    >> >in the properties window while the page is open in

    design
    >> view. There's no
    >> >need to code it yourself in the HTML view.
    >> >
    >> >
    >> >> I'm thinking of removing them from the properties

    window
    >> >> and also resorting to a pure HTML control rather

    than a
    >> >> server-based Web control, but I'm struggling with

    why I
    >> >> have to do this.
    >> >>
    >> >> Thanks again!
    >> >> Mike
    >> >> >-----Original Message-----
    >> >> >Have you set the width of the label? Labels render

    as
    >> >> SPAN tags in the
    >> >> >resulting HTML and if you have specified a width,

    that
    >> >> will appear as an
    >> >> >inline style attribute of the SPAN tag. If this

    does
    >> not
    >> >> work in a browser,
    >> >> >then that browser does not support CSS.
    >> >> >
    >> >> >
    >> >> >"Mike Casey" <>

    >> wrote
    >> >> in message
    >> >> >news:01db01c3c4e3$fbf91050$...
    >> >> >> Hello all,
    >> >> >> I have ASP.NET label controls tied to a datasource

    >> (so
    >> >> >> text will vary in length depending on the record).

    >> In
    >> >> IE
    >> >> >> everything looks great--text is wrapped if needed.

    >> In
    >> >> >> Netscape and Opera, the text extends horizontally

    and
    >> >> does
    >> >> >> not wrap.
    >> >> >>
    >> >> >> Any ideas would be most appreciated!
    >> >> >>
    >> >> >> Thanks,
    >> >> >> Mike
    >> >> >
    >> >> >
    >> >> >.
    >> >> >
    >> >
    >> >
    >> >.
    >> >

    >
    >
    >.
    >
    Mike Casey, Dec 19, 2003
    #7
  8. Mike Casey

    Scott M. Guest

    No, that is the Web Form Label (System.Web.UI.WebControls.Label).

    All web form controls render in the client as HTML, so the web form label
    control renders as a span tag. Any modifications to the look/feel/position
    of the label in the properties window render as style attribute values to
    the span tag.

    Let's see what HTML you are getting in your browser if you use a web form
    label.


    "Mike Casey" <> wrote in message
    news:05f301c3c64b$66e0ef10$...
    > AH...actually that is the HTML label you are adding,
    > right? If I add the Web Forms Label control, the tags are
    > handled differently...
    > >-----Original Message-----
    > >I'm not sure you are following my instructions or you may

    > have a problem
    > >with your VS installation.
    > >
    > >If I put a label on a webform and then change its height

    > and width
    > >properties in the property window and then run the

    > project, I get the
    > >following HTML sent to my client:
    > >
    > ><span id="Label1"

    > style="height:75px;width:100px">Label</span>
    > >
    > >Note that the height and width are attribute values for

    > the style attribute
    > >of the span tag. This is the correct behavior. I'm not

    > sure what you mean
    > >by the parameters appearing by themselves in HTML outside

    > of the style tag,
    > >but if you are not getting the same results as I'm

    > showing above, then
    > >something is wrong.
    > >
    > >
    > >"Mike Casey" <> wrote

    > in message
    > >news:085101c3c635$2e826650$...
    > >> I'm thinking there might be a reason in this case. If

    > you
    > >> make changes in the properties window, the Width and
    > >> Height parameters appear by themselves in HTML, outside

    > of
    > >> the Style tag. I'm thinking that some browsers might

    > not
    > >> recognize these values unless they are within the Style
    > >> tag. Maybe?
    > >> >-----Original Message-----
    > >> >
    > >> >"Mike Casey" <>

    > wrote
    > >> in message
    > >> >news:07d701c3c568$5bef0e90$...
    > >> >> Thanks! I specify the width and height directly in

    > the
    > >> >> HTML view of the page. I've noticed that making this
    > >> >> change within the "Style" parameters (HEIGHT: 42px;
    > >> WIDTH:
    > >> >> 100px;) works temporarily. However after recompiling
    > >> the
    > >> >> application, the height and width attributes appear
    > >> again
    > >> >> outside the Style tag (I assume this is because they

    > are
    > >> >> set in the property window / Design view of the

    > server
    > >> >> control).
    > >> >>
    > >> >
    > >> >Not sure what you mean here. You can easily just set

    > the
    > >> width of the label
    > >> >in the properties window while the page is open in

    > design
    > >> view. There's no
    > >> >need to code it yourself in the HTML view.
    > >> >
    > >> >
    > >> >> I'm thinking of removing them from the properties

    > window
    > >> >> and also resorting to a pure HTML control rather

    > than a
    > >> >> server-based Web control, but I'm struggling with

    > why I
    > >> >> have to do this.
    > >> >>
    > >> >> Thanks again!
    > >> >> Mike
    > >> >> >-----Original Message-----
    > >> >> >Have you set the width of the label? Labels render

    > as
    > >> >> SPAN tags in the
    > >> >> >resulting HTML and if you have specified a width,

    > that
    > >> >> will appear as an
    > >> >> >inline style attribute of the SPAN tag. If this

    > does
    > >> not
    > >> >> work in a browser,
    > >> >> >then that browser does not support CSS.
    > >> >> >
    > >> >> >
    > >> >> >"Mike Casey" <>
    > >> wrote
    > >> >> in message
    > >> >> >news:01db01c3c4e3$fbf91050$...
    > >> >> >> Hello all,
    > >> >> >> I have ASP.NET label controls tied to a datasource
    > >> (so
    > >> >> >> text will vary in length depending on the record).
    > >> In
    > >> >> IE
    > >> >> >> everything looks great--text is wrapped if needed.
    > >> In
    > >> >> >> Netscape and Opera, the text extends horizontally

    > and
    > >> >> does
    > >> >> >> not wrap.
    > >> >> >>
    > >> >> >> Any ideas would be most appreciated!
    > >> >> >>
    > >> >> >> Thanks,
    > >> >> >> Mike
    > >> >> >
    > >> >> >
    > >> >> >.
    > >> >> >
    > >> >
    > >> >
    > >> >.
    > >> >

    > >
    > >
    > >.
    > >
    Scott M., Dec 19, 2003
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. msnews.microsoft.com
    Replies:
    1
    Views:
    555
    =?Utf-8?B?RG90TmV0SmVyb21l?=
    Feb 22, 2005
  2. CSharpner
    Replies:
    0
    Views:
    1,000
    CSharpner
    Apr 9, 2007
  3. KJ

    asp:label not wrapping

    KJ, Jun 24, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    122
    Scott M.
    Jun 24, 2004
  4. Himanshu

    Wrapping Text in Tree View Control in ASP.Net

    Himanshu, Mar 3, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    120
    MasterGaurav
    Mar 3, 2005
  5. Knut Krueger
    Replies:
    8
    Views:
    254
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page