Click here to Skip to main content
Licence GPL3
First Posted 5 Jan 2008
Views 16,156
Downloads 39
Bookmarked 19 times

Expansion UpdatePanel control - solve problems layout design stage

By jeff377 | 5 Jan 2008 | Unedited contribution
resolve the UpdatePanel layout design stage an abnormal state
3 votes, 100.0%
1

2

3

4

5
1.00/5 - 3 votes
μ 1.00, σa 1.10 [?]

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 (GPLv3)

About the Author

jeff377

Web Developer

Taiwan Taiwan

Member


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 1 PinmemberGroovBird3:19 17 Feb '10  
GeneralLost in Translation PinmemberGroovBird3:16 17 Feb '10  
GeneralMy vote of 1 PinmemberNeem120:19 27 Aug '09  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120206.1 | Last Updated 5 Jan 2008
Article Copyright 2008 by jeff377
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid