locked
changing Label font RRS feed

  • Question

  • User657133461 posted

    hello i am giving the user many options one of them is the option to change the font of some of the labels.  
    the problem i am having is :
    i got labels with a written text field  +  labels which getting filled from the data source  like :
    Phone :   XXXX          .    the part that comes from the data source ( XXXX )  changes the font as needed while the "Phone"  label aint.
    i am working with VB

    for example : 
    NameLbl.Font.Name = GridView1.Rows(0).Cells(1).Text  (has a text value)

    NameInputLbl.font.Name = GridView1.Rows(0).Cells(1).Text  (gets a text value from the data source)

    i checked and it seems both getting  the font changed but in the end of the proccess

    only the NameInputLbl shows the new font of the text.

    Wednesday, September 19, 2012 10:27 AM

Answers

  • User632635755 posted

    You can easily change the font in ASP.Net by using the Style property.

    NameLbl.Style.Add(HtmlTextWriterStyle.FontFamily, GridView1.Rows(0).Cells(1).Text)

    If this doesn't work, the font may be getting changed somewhere else between this code and when the control is rendered.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 19, 2012 11:29 AM
  • User657133461 posted

    i found the problem, the text value was written in a not supported language of the font.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 20, 2012 2:48 AM

All replies

  • User632635755 posted

    You can easily change the font in ASP.Net by using the Style property.

    NameLbl.Style.Add(HtmlTextWriterStyle.FontFamily, GridView1.Rows(0).Cells(1).Text)

    If this doesn't work, the font may be getting changed somewhere else between this code and when the control is rendered.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 19, 2012 11:29 AM
  • User657133461 posted

    i guess i got a problem in some other part of the code because i tried it and the result was the same.
    label with  text value of ""  changes to the choosen font  after the text value getting filled from the data source while the label with the perement text value   "Phone:"   wont change the font . 

    Thursday, September 20, 2012 2:30 AM
  • User657133461 posted

    i found the problem, the text value was written in a not supported language of the font.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 20, 2012 2:48 AM