locked
BreakAfter and <br /> RRS feed

  • Question

  • User512894520 posted

    I know this query has been posted numerous times in the Forum but I couldn't find the answer I am looking for. A lot of posts ask for a solution if the BreakAfter property of a control doesn't really result in line-break in some spcific device. The solution proposed by most is to add a <br /> tag manually in the Server script. How do I do this programatically. If my controls are created in the run-time then how do I specifically add a <br /> tag after that control (incase breakAfter does not work). Is there any mechanism to add such "html" tags to say a page.ActiveForm.Controls section.

     

    Wednesday, January 3, 2007 10:03 AM

All replies

  • User1001868398 posted

    On you Render function:

    protected override void Render(HtmlTextWriter writer)

            {

                AddAttributesToRender(writer);

     

                writer.AddAttribute(

                    HtmlTextWriterAttribute.Cellpadding,

                    "1", false);

                writer.RenderBeginTag(HtmlTextWriterTag.Table);

     

                writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                writer.RenderBeginTag(HtmlTextWriterTag.Td);

                m_Control1.RenderControl(writer);

                writer.RenderEndTag();

                writer.RenderBeginTag(HtmlTextWriterTag.Td);

                m_Control2.RenderControl(writer);

                writer.RenderEndTag();           

                writer.RenderEndTag();

                           

                writer.RenderEndTag();

                writer.WriteLine("<BR>");

     

            }

    Wednesday, January 3, 2007 3:43 PM
  • User512894520 posted

    Thanks a bunch for replying. I had given up all hope of ever receiving a response on this Forum, hence the delay in this post. :-)
    The Render mehod that you have asked me to override is, I think, the render for the Mobile Webform Page class. Is it so? I understand that this may sound infinitely stupid but I do not understand the solution suggested. What I was looking for, is a simple mechanism to forcefully introduce a line-break both in HTML and WML rendered pages.
    When I construct a Mobile WebForm with two dynamic controls, say two links (or rather MobileLinks), I explicitly set their BreakAfter properties to true.
    For eg.
    System.Web.UI.MobileControls.Link link1 = new System.Web.UI.MobileControls.Link();
    link1.BreakAfter = true;
    link1.NavigateUrl = "Page1.aspx";
    this.ActiveForm.Controls.Add(link1);

    and similarly for link2. Now this content, on HTML pages is rendered on different lines, one after the other, as expected. But on some WML phones it appears on the same line. Here again, I understand that ASP.Net claims to render what is best for the device in question. But I specifically want to introduce a <BR /> tag after these controls and I am sure WML, however limited in its UI capabilities, allows a tag as simple as this. Now, I couldn't find a Mobile:LineBreak kind of control like a Mobile:Link control. The intent of the orginal post was to ascertain as to whether such a control/tagelement exists for Mobile Webforms.

    Following is what I think I've understood from your post:
    After I have added the above controls on the Page_load of my Mobile Webform aspx, before it is finally rendered and sent as an HTML or WML content, I should retrieve my dynamic controls from the Page.ActiveForm object using, say FindControl(), and then call RenderControl for the every dynamic control and interperse an <Br /> wherever applicable. I don't understand the above statement completely even as I write it. :-)

    So please help!!

    Thanks lot for the first response anyway. 

    Friday, January 5, 2007 1:34 AM