Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Wrap Text in a Label? 1

Status
Not open for further replies.

mark929

Programmer
Nov 30, 2001
67
US
I am inputing text into a text box on one form, then passing it to a label on another form. The text will wrap in the textbox on the input form, but will not wrap in the label. It just continues in a single line on the output form. I have even tried to put the label in a table to contain the text and force it to wrap, but the table just expands with the single line of text. I have also checked the "Wrap Text" checkbox property in the table with no luck. I just need to have the output text wrap to about the same size as the input text.

Any ideas about what I may be doing wrong, or suggestions of perhaps another way of doing this?

Thanks

Mark
 
mark, can you post the relevant bits of code so we can see what is going on? thanks!

i love chocolate
 
I'm not quite sure what code to send, so here's both Input and Output ASPX.vb code. Everything works except for the ouput labels not wrapping the text from the input textbox.

Thanks for your time.

Mark


----------------------------------------------

***Code from TeleCommFormOutput.aspx.vb***


Public Class TeleCommOutput
Inherits System.Web.UI.Page

Protected WithEvents lblName As System.Web.UI.WebControls.Label
Protected WithEvents lblTitle As System.Web.UI.WebControls.Label
Protected WithEvents lblSeries As System.Web.UI.WebControls.Label
Protected WithEvents lblGrade As System.Web.UI.WebControls.Label
Protected WithEvents lblOrganization As System.Web.UI.WebControls.Label
Protected WithEvents lblSupervisor As System.Web.UI.WebControls.Label
Protected WithEvents lblTypeRequest As System.Web.UI.WebControls.Label
Protected WithEvents lblLimitations As System.Web.UI.WebControls.Label
Protected WithEvents lblDuration As System.Web.UI.WebControls.Label
Protected WithEvents lblLocation As System.Web.UI.WebControls.Label
Protected WithEvents lblDeliverables1 As System.Web.UI.WebControls.Label
Protected WithEvents lblTimeSpent1 As System.Web.UI.WebControls.Label
Protected WithEvents lblDeliverables2 As System.Web.UI.WebControls.Label
Protected WithEvents lblTimeSpent2 As System.Web.UI.WebControls.Label
Protected WithEvents lblDeliverables3 As System.Web.UI.WebControls.Label
Protected WithEvents lblSchedules As System.Web.UI.WebControls.Label
Protected WithEvents lblW1OffMon As System.Web.UI.WebControls.Label
Protected WithEvents lblW1OffTue As System.Web.UI.WebControls.Label
Protected WithEvents lblW1OffWed As System.Web.UI.WebControls.Label
Protected WithEvents lblW1OffThu As System.Web.UI.WebControls.Label
Protected WithEvents lblW1OffFri As System.Web.UI.WebControls.Label
Protected WithEvents lblW1AltMon As System.Web.UI.WebControls.Label
Protected WithEvents lblW1AltTue As System.Web.UI.WebControls.Label
Protected WithEvents lblW1AltWed As System.Web.UI.WebControls.Label
Protected WithEvents lblW1AltThu As System.Web.UI.WebControls.Label
Protected WithEvents lblW1AltFri As System.Web.UI.WebControls.Label
Protected WithEvents lblW2OffMon As System.Web.UI.WebControls.Label
Protected WithEvents lblW2OffTue As System.Web.UI.WebControls.Label
Protected WithEvents lblW2OffWed As System.Web.UI.WebControls.Label
Protected WithEvents lblW2OffThu As System.Web.UI.WebControls.Label
Protected WithEvents lblW2OffFri As System.Web.UI.WebControls.Label
Protected WithEvents lblW2AltMon As System.Web.UI.WebControls.Label
Protected WithEvents lblW2AltTue As System.Web.UI.WebControls.Label
Protected WithEvents lblW2AltWed As System.Web.UI.WebControls.Label
Protected WithEvents lblW2AltThu As System.Web.UI.WebControls.Label
Protected WithEvents lblW2AltFri As System.Web.UI.WebControls.Label
Protected WithEvents lblWorksite2 As System.Web.UI.WebControls.Label
Protected WithEvents lblDurationStart As System.Web.UI.WebControls.Label
Protected WithEvents lblDurationEnd As System.Web.UI.WebControls.Label
Protected WithEvents lblTimeSpent3 As System.Web.UI.WebControls.Label
Protected WithEvents lblTask2 As System.Web.UI.WebControls.Label
Protected WithEvents lblTask3 As System.Web.UI.WebControls.Label
Protected WithEvents lblAddress As System.Web.UI.WebControls.Label
Protected WithEvents lblAltWorksite As System.Web.UI.WebControls.Label
Protected WithEvents lblTelephone As System.Web.UI.WebControls.Label
Protected WithEvents lblTask1 As System.Web.UI.WebControls.Label


Protected MyTask1 As String

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim MyFormData As TeleCommData = CType(HttpContext.Current.Items(&quot;TeleCommData&quot;), TeleCommData)

lblName.Text = MyFormData.Name
lblTitle.Text = MyFormData.Title
lblSeries.Text = MyFormData.Series
lblGrade.Text = MyFormData.Grade
lblOrganization.Text = MyFormData.Organization
lblTelephone.Text = MyFormData.Telephone
lblSupervisor.Text = MyFormData.Supervisor
lblTypeRequest.Text = MyFormData.TypeRequest
lblLimitations.Text = MyFormData.Limitations
lblDuration.Text = MyFormData.Duration
lblLocation.Text = MyFormData.Location
lblTask1.Text = MyFormData.Task1
lblDeliverables1.Text = MyFormData.Deliverables1
lblTimeSpent1.Text = MyFormData.TimeSpent1
lblTask2.Text = MyFormData.Task2
lblDeliverables2.Text = MyFormData.Deliverables2
lblTimeSpent2.Text = MyFormData.TimeSpent2
lblTask3.Text = MyFormData.Task3
lblDeliverables3.Text = MyFormData.Deliverables3
lblSchedules.Text = MyFormData.Schedules
lblW1OffMon.Text = MyFormData.W1OffMon
lblW1OffTue.Text = MyFormData.W1OffTue
lblW1OffWed.Text = MyFormData.W1OffWed
lblW1OffThu.Text = MyFormData.W1OffThu
lblW1OffFri.Text = MyFormData.W1OffFri
lblW1AltMon.Text = MyFormData.W1AltMon
lblW1AltTue.Text = MyFormData.W1AltTue
lblW1AltWed.Text = MyFormData.W1AltWed
lblW1AltThu.Text = MyFormData.W1AltThu
lblW1AltFri.Text = MyFormData.W1AltFri
lblW2OffMon.Text = MyFormData.W2OffMon
lblW2OffTue.Text = MyFormData.W2OffTue
lblW2OffWed.Text = MyFormData.W2OffWed
lblW2OffThu.Text = MyFormData.W2OffThu
lblW2OffFri.Text = MyFormData.W2OffFri
lblW2AltMon.Text = MyFormData.W2AltMon
lblW2AltTue.Text = MyFormData.W2AltTue
lblW2AltWed.Text = MyFormData.W2AltWed
lblW2AltThu.Text = MyFormData.W2AltThu
lblW2AltFri.Text = MyFormData.W2AltFri
lblAltWorksite.Text = MyFormData.AltWorksite
lblWorksite2.Text = MyFormData.Worksite
lblDurationStart.Text = MyFormData.DurationStart
lblDurationEnd.Text = MyFormData.DurationEnd
lblTimeSpent3.Text = MyFormData.TimeSpent3
lblAddress.Text = MyFormData.Address
End Sub

End Class
--------------------------------------------------------


***Code from TeleCommFormInput.aspx.vb***

Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents TxtBxOrganization As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxTelephone As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxName As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxTitle As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxSeries As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxGrade As System.Web.UI.WebControls.TextBox
Protected WithEvents RdBtnTypeRequest As System.Web.UI.WebControls.RadioButtonList
Protected WithEvents RdBtnLimitations As System.Web.UI.WebControls.RadioButtonList
Protected WithEvents TxtBxDurationStart As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxDurationEnd As System.Web.UI.WebControls.TextBox
Protected WithEvents RdBtnDuration As System.Web.UI.WebControls.RadioButtonList
Protected WithEvents TxtBxLocation As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxAddress As System.Web.UI.WebControls.TextBox
Protected WithEvents RdBtnWorksite2 As System.Web.UI.WebControls.RadioButtonList
Protected WithEvents RdbtnSchedules As System.Web.UI.WebControls.RadioButtonList
Protected WithEvents TxtBxTasks1 As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxDeliverables1 As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxTimeSpent1 As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxTasks2 As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxDeliverables2 As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxTimeSpent2 As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxTasks3 As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxDeliverables3 As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxTimeSpent3 As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxAltWorksite As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW1OffMon As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW1AltMon As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW1OffTue As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW1AltTue As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW1OffWed As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW1AltWed As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW1OffThu As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW1AltThu As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW1OffFri As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW1AltFri As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW2OffMon As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW2AltMon As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW2OffTue As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW2AltTue As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW2OffWed As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW2AltWed As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW2OffThu As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW2AltThu As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW2OffFri As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtBxW2AltFri As System.Web.UI.WebControls.TextBox
Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button
Protected WithEvents btnReset As System.Web.UI.WebControls.Button
Protected WithEvents RdBtnWorksite As System.Web.UI.WebControls.RadioButtonList
Protected WithEvents TxtBoxSupervisor As System.Web.UI.WebControls.TextBox

#Region &quot; Web Form Designer Generated Code &quot;

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Reset1_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Response.Redirect(&quot; End Sub

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
'Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items(&quot;PortalSettings&quot;), PortalSettings)
Dim MyFormInput As TeleCommData
MyFormInput = New TeleCommData()

MyFormInput.Name = TxtBxName.Text
MyFormInput.Title = TxtBxTitle.Text
MyFormInput.Organization = TxtBxOrganization.Text
MyFormInput.Telephone = TxtBxTelephone.Text
MyFormInput.Series = TxtBxSeries.Text
MyFormInput.Grade = TxtBxGrade.Text
MyFormInput.TypeRequest = RdBtnTypeRequest.SelectedItem.Text
MyFormInput.Limitations = RdBtnLimitations.SelectedItem.Text
MyFormInput.DurationStart = TxtBxDurationStart.Text
MyFormInput.DurationEnd = TxtBxDurationEnd.Text
MyFormInput.Duration = RdBtnDuration.SelectedItem.Text
MyFormInput.Location = TxtBxLocation.Text
MyFormInput.Address = TxtBxAddress.Text
MyFormInput.Task1 = TxtBxTasks1.Text
MyFormInput.Deliverables1 = TxtBxDeliverables1.Text
MyFormInput.TimeSpent1 = TxtBxTimeSpent1.Text
MyFormInput.Task2 = TxtBxTasks2.Text
MyFormInput.Deliverables2 = TxtBxDeliverables2.Text
MyFormInput.TimeSpent2 = TxtBxTimeSpent2.Text
MyFormInput.Task3 = TxtBxTasks3.Text
MyFormInput.Deliverables3 = TxtBxDeliverables3.Text
MyFormInput.TimeSpent3 = TxtBxTimeSpent3.Text
MyFormInput.Worksite = RdBtnWorksite.SelectedItem.Text
MyFormInput.Schedules = RdbtnSchedules.SelectedItem.Text
MyFormInput.W1OffMon = TxtBxW1OffMon.Text
MyFormInput.W1AltMon = TxtBxW1AltMon.Text
MyFormInput.W1OffTue = TxtBxW1OffTue.Text
MyFormInput.W1AltTue = TxtBxW1AltTue.Text
MyFormInput.W1OffWed = TxtBxW1OffWed.Text
MyFormInput.W1AltWed = TxtBxW1AltWed.Text
MyFormInput.W1OffThu = TxtBxW1OffThu.Text
MyFormInput.W1AltThu = TxtBxW1AltThu.Text
MyFormInput.W1OffFri = TxtBxW1OffFri.Text
MyFormInput.W1AltFri = TxtBxW1AltFri.Text
MyFormInput.W2OffMon = TxtBxW2OffMon.Text
MyFormInput.W2AltMon = TxtBxW2AltMon.Text
MyFormInput.W2OffTue = TxtBxW2OffTue.Text
MyFormInput.W2AltTue = TxtBxW2AltTue.Text
MyFormInput.W2OffWed = TxtBxW2OffWed.Text
MyFormInput.W2AltWed = TxtBxW2AltWed.Text
MyFormInput.W2OffThu = TxtBxW2OffThu.Text
MyFormInput.W2AltThu = TxtBxW2AltThu.Text
MyFormInput.W2OffFri = TxtBxW2OffFri.Text
MyFormInput.W2AltFri = TxtBxW2AltFri.Text
MyFormInput.Supervisor = TxtBoxSupervisor.Text
MyFormInput.AltWorksite = TxtBxAltWorksite.Text


HttpContext.Current.Items.Add(&quot;Telecommform&quot;, MyFormInput)
Response.Redirect(&quot;~/TeleCommOutput.aspx&quot;)
End Sub
End Class
 
I am not sure exactly how much text you are trying to wrap, but by setting the label to a defined width, whether directly in the property window, or by sizing it to your desired size in design view, the text should wrap. This works on my page fine.
 
I am only trying to wrap a few sentences or perhaps a small paragraph. I am setting the size in Label Properties\Layout\Height & Width. It still will not hold the size. It still runs the text out in a single string. To the point of the horizontal scroll bar appearing in my browser. I had sized the output label, the same size as the input text box in an attempt to create a similar text view. But, it still appears single line in the output label. I thought there may be a multi-line property similar to a text box, but I can't find one.

Thanks for looking at this. If anything else comes to mind, please let me know.

Thanks

Mark
 
the only thing that comes to mind is to change the page layout property from grid to flow.

Try that and see what happens

John
 
I changed it to Grid layout, but still no wrap. I know it should be wrapping, but it's not. I've had several coworkers look at it, and we're all stumped. I appeciate your time and input. I'll continue working with it and perhaps find the answer (someday).

Thanks Again,

Mark

 
Try this:

In Grid mode, set your width to the size you want, and leave the height blank. This will allow the label to grow vertically rather than horizontally. This should result in your words wraping.:)


Hope this helps!

 
Isn't GridLayout the one where all elements are positioned absolute?
Absolute positioned elements are elements that are put on a page at a certain top and left (like sticking a sticker), if the elements are not positioned absolute they are stacked on top and next to each other. So when elements have a variable height and or with the change is that they will overlap each other.
How would you prevent that?
 
Thanks WebWzrd,

That was a good idea, but it's still not wrapping. Changing to grid layout, and sizing only the width didn't seem to make any difference. I'm about to give up on the output label and try some other way to display the text.

I appreciate your suggestion. If you have any other ideas, please let me know.

Thanks

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top