Literal control won't expand

M

Mark A. Sam

Hello,

I am trying to use a literal control to past test onto a page from several
buttons, so that each button displays something different. The problem I am
encountering is that the text wraps according to the width of the literal,
which is the width then it is put on the page. The other day I played with
this and had no problem. I assigned the text to the literal and it went
onto the page as it should have. I tried using html tags with line breaks,
as well as trying to place a panel onto the page through the literal, to
force the width, but no success.

Dim str As String

str = "<asp:panel ID='Panel1' runat='server' BorderColor='Black'
BorderWidth='4px' Height='25px' Style='position: static' Width='540px'>"

str = str & "This is a test1. This is a test2. This is a test3. This is a
test4. This is a test5.</asp:panel>"

LitMessage.Text = str

It displayed the text, but not the panel.

Does anyone have any idea what the problem is, or is it just another
Microsoft thang?

Thank you and God Bless,

Mark A. Sam
 
M

Mark A. Sam

This has nothing to do with the literal control. Its just another
unexplainable issue with a Microsoft product. Enough said.
 
V

Vadivel Kumar

IMHO, I can say your understanding towards the ASP.NET concepts are to
be slightly reconsidered.

This is not the right way of placing an Panel (or any other server
control) inside a server control. I think, MS doesn't make any thing
that wont make sense, because the code you pasted here works properly as
per its nature, but not as per your expectation.

Basically, you have to understand that the code is first executed in the
server side and sent to the client, so as per your code what happens is
the "str" will compiled to sent as a "normal text" to the LitMessage
control's text property. So you would end up in seeing the text rather
then the panel control.

The right code would look similar to this (this code is in C#),

Panel objPanel = new Panel();

Literal objLiteral = new Literal("This is a test1");
objPanel.Controls.Add(objLiteral);

// I am assuming LitMessage is any other webcontrol that is
// already placed in the page.
LitMessage.Controls.Add (objPanel);

Is that makes sense? If you could understand the code, you can see the
cleanliness and how it is more well-formed.

Let me know if you need further information.

-
Vadivel Kumar
http://vadivelk.net
 
M

Mark A. Sam

Vadivel,

Really it doesn't make sense. According to information I had, a literal
accepts html. So it would be my understanding that if I assigned it code
directly from the webpage, it would know how to interpret it. It was an
error in my thinking.

Here is the problem. I type directly onto the webpage. I typed a line of
text across the page and let it wrap to the second line. Then I opened the
source to look at the html and went back into designview. The line of text
I entered was now unched up on the left side of the page. This also happens
usually when I type directly into tables, then I have to add Panel to force
the text across the page or cell. It is difficult to know how controls are
to work, becuase normal things don't act normally. This is true of all
Microsoft products. It's one goofy thing after another. It's frustrating.
;)

God Bless,

Mark
 
M

Mark A. Sam

Vadivel Kumar said:
Anyways, Did you understand the code and tried to solve the problem?

No, I solved it another way. I placed a literal control inside of a panel
control, then sized the width of the panel. I then applied code to the
literal control like this:

Protected Sub btnIntro_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnIntro.Click

Dim str As String

str = "<span style='font-size: 14pt'>"""

str = str & "Promote Ministries is an independent ministry with a mission of
reaching young people for Jesus Christ. We are a group of servants called
together into this ministry, to be independent of a Church or other
organization, where politics are apt to bind our hands and prevent us from
serving to our fullest capacity. We don't feel that all ministry should be
carried out this way, but that we are called to this format. </br></br>"

str = str & "If you feel called to work in Youth Ministry, we would like to
talk to you, however, know that a lot will be required of you. You will be
asked to make a commitment to focus on the work of the ministry and put if
ahead of your other interests, including family and friends. You will be
asked, in other words to put God's work first (Luke 18:22, Luke 9:59-62,
Matthew 10:35-37). </br>"

str = str & "</span>"

LitMessage.Text = str

End Sub

I have other buttons which apply text to the literal control and this works
perfectly.

The problem is typing or applying text inside of a table. Visual Web
Developer Express doesn't like it. So it requires another container,
specifically a panel to enable you to control the width of the text area.

Thank you for your responses.

God Bless,

Mark
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top