Literal control won't expand

Discussion in 'ASP .Net' started by Mark A. Sam, Jun 28, 2006.

  1. Mark A. Sam

    Mark A. Sam Guest

    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
    Mark A. Sam, Jun 28, 2006
    #1
    1. Advertising

  2. Mark A. Sam

    Mark A. Sam Guest

    Forget it

    This has nothing to do with the literal control. Its just another
    unexplainable issue with a Microsoft product. Enough said.
    Mark A. Sam, Jun 28, 2006
    #2
    1. Advertising

  3. Re: Literal control won't expand [You should read this]

    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









    Mark A. Sam wrote:
    > 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
    >
    >
    >
    >
    >
    >
    >
    Vadivel Kumar, Jun 28, 2006
    #3
  4. Mark A. Sam

    Mark A. Sam Guest

    Re: Literal control won't expand [You should read this]

    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


    "Vadivel Kumar" <> wrote in message
    news:...
    > 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
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > Mark A. Sam wrote:
    >> 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
    >>
    >>
    >>
    >>
    >>
    >>
    Mark A. Sam, Jun 28, 2006
    #4
  5. Re: Literal control won't expand [You should read this]

    Anyways, Did you understand the code and tried to solve the problem?

    --
    Vadivel Kumar
    http://www.vadivelk.net
    (remove "online.")

    Mark A. Sam wrote:
    > 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
    >
    >
    > "Vadivel Kumar" <> wrote in message
    > news:...
    >> 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
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >> Mark A. Sam wrote:
    >>> 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
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>

    >
    Vadivel Kumar, Jun 28, 2006
    #5
  6. Mark A. Sam

    Mark A. Sam Guest

    Re: Literal control won't expand [You should read this]

    "Vadivel Kumar" <> wrote in message
    news:%23ve%...
    > 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
    Mark A. Sam, Jun 28, 2006
    #6
    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. Chad
    Replies:
    4
    Views:
    8,308
  2. Replies:
    1
    Views:
    597
    T. Church
    Jul 16, 2007
  3. Replies:
    0
    Views:
    298
  4. Anonieko Ramos

    What's wrong with rpc-literal? Why use doc-literal?

    Anonieko Ramos, Sep 27, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    362
    Anonieko Ramos
    Sep 27, 2004
  5. Paul Taylor
    Replies:
    2
    Views:
    142
    bbiker
    Aug 30, 2010
Loading...

Share This Page