Click here to Skip to main content
6,822,613 members and growing! (15,778 online)
Email Password   helpLost your password?
Web Development » Ajax and Atlas » Controls License: The GNU General Public License (GPL)

Expansion UpdatePanel control - solve problems layout design stage

By jeff377

resolve the UpdatePanel layout design stage an abnormal state
ASP.NET
Posted:5 Jan 2008
Views:11,317
Bookmarked:17 times
Unedited contribution
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
2 votes for this article.
Popularity: 0.30 Rating: 1.00 out of 5
2 votes, 100.0%
1

2

3

4

5

Introduction

Use ASP.NET AJAX developers, we will not miss this super UpdatePanel control, it can be easy to let the original design pages easily with AJAX results. But at the design stage to the use of typesetting UpdatePanel often our troubled placed in the control of the UpdatePanel not show the actual layout correct the situation.

For example we only simply lay aside TextBox and the Button two controls items in UpdatePanel

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                <asp:Button ID="Button2" runat="server" Text="Button" />
    </ContentTemplate>
</asp:UpdatePanel>  

Button and TextBox theoretically should be in the same line, but in the design of the page to see the results, even after newline TextBox only showed Button, as shown below. But the run-time also to the normal, this result will be displayed in the design of complex pages often cause considerable problems.

Using the code

Some people's methods are lay aside Panel in UpdatePanel, the Panel set a fixed width width (800 px), to resolve the UpdatePanel layout design stage an abnormal state.

In fact UpdatePanel would cause such results at the design stage, is in the design stage UpdatePanel output HTML code did not set width, so we have inherited UpdatePanel down a new TBUpdatePanel rewrite, rewrite and re-adjust its output Designer design phase of the HTML code to solve this problem.

We first looked TBUpdatePanel the result, back relates in detail the revision way again. Same, only simply lays aside TextBox and the Button two controls items in TBUpdatePanel.

<bee:TBUpdatePanel ID="TBUpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" />
    </ContentTemplate>
</bee:TBUpdatePanel> 

In the design of the results page, shown below.

Actually revises the way certainly imagines you simply to be very more than, first composes TBUpdatePanel to inherit UpdatePanel, revises its Designer is only TBUpdatePanelDesigner.

    < _
    Designer(GetType(TBUpdatePanelDesigner)), _
    ToolboxData("<{0}:TBUpdatePanel runat="server"></{0}:TBUpdatePanel>") _
    > _
    Public Class TBUpdatePanel
        Inherits System.Web.UI.UpdatePanel

    End Class

How again comes is composes TBUpdatePanelDesigner, TBUpdatePanelDesigner inherits UpdatePanel original UpdatePanelDesigner, covers writes the GetDesignTimeHtml method to readjust the output HTML code. UpdatePanelDesigner the originally output HTML code following chart shows.

Very obviously, its most outer layer table by no means assigns witdh only then to be able to cause the design stage the unusual situation, therefore we so long as suppose table width are 100% may solve this question. The TBUpdatePanelDesigner complete formula code is as follows, the so simple revision was allowed forever to get rid of UpdatePanel the typesetting to puzzle.

    ''' <summary>
    ''' Expansion TBUpdatePanel control of the design of model behavior.
    ''' </summary>
    Public Class TBUpdatePanelDesigner
        Inherits System.Web.UI.Design.UpdatePanelDesigner

        Public Overrides Function GetDesignTimeHtml(ByVal regions As DesignerRegionCollection) As String
            Dim sHTML As String

            sHTML = MyBase.GetDesignTimeHtml(regions)
            sHTML = Left(sHTML, 7) & " width=""100%"" " & Mid(sHTML, 8)
            Return sHTML
        End Function
    End Class 

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPL)

About the Author

jeff377


Member

Occupation: Web Developer
Location: Taiwan Taiwan

Other popular Ajax and Atlas articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 1 of 1 (Total in Forum: 1) (Refresh)FirstPrevNext
GeneralMy vote of 1 PinmemberNeem120:19 27 Aug '09  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.

PermaLink | Privacy | Terms of Use
Last Updated: 5 Jan 2008
Editor:
Copyright 2008 by jeff377
Everything else Copyright © CodeProject, 1999-2010
Web19 | Advertise on the Code Project