VB.NET Code Behind Page Postback Problem!

  1. #1

    VB.NET Code Behind Page Postback Problem!

    Hello, Have built a screen with only the placeholder in HTML. All code is in VB Code Behind.

    When I load the page, Everything loads fine. When I try to add something with a button click the entire screen refreshes. Is there a way to fix this. and brings back the new page, with new content.

    Is there a way to not refresh the screen but make the changes appear from Code Behind?

    Thanks

    Tom
  2. #2

    RE: VB.NET Code Behind Page Postback Problem!

    Review the examples portion of this website - specifically Events -> AjaxMethods and AjaxEvents. The examples show how to use a button click and not do a full page postback.

    Cheers~


  3. #3

    RE: VB.NET Code Behind Page Postback Problem!

    Thanks for you reply, Can you supply a link to the correct sample, I have seen many ways to do this and still haven't found a working solution. I have the onLoad creating the screen and then was trying to use a button to add a portlet. Works fine except for the screen refresh.

    Thanks Again
  4. #4

    RE: VB.NET Code Behind Page Postback Problem!

    You are trying to add new controls to the page? I thought you were looking to make data changes to existing controls. In the current version controls can not be created during Ajax events.

    http://forums.ext.net/showthread.php...t=ajax+control

    If you search the forum for ajax control you'll find quite a few other posts where people are trying to do the same thing. You'll have to wait until the next release.

    Cheers~
  5. #5

    RE: VB.NET Code Behind Page Postback Problem!

    Thanks, Guess I will be waiting for a new version.
  6. #6

    RE: VB.NET Code Behind Page Postback Problem!

    See below for the code that I am running. This works to create the page. No HTML, just Content Place Holder.


    CodeOnly.aspx

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="CodeOnly.aspx.vb" Inherits="CooliteSite.CodeOnly" %>
    <%@ Register assembly="Coolite.Ext.Web, Version=0.8.1.987, Culture=neutral, PublicKeyToken=f58c952e9aa5b80a" namespace="Coolite.Ext.Web" tagprefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    
    
    </head>
    
    <body>
    
        <form id="form1" runat="server">
    
        
            <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
           
    
        
    
        
    
        </form>
    </body>
    </html>

    CodeOnly.vb

    Imports Coolite.Ext.Web
    Imports Coolite.Utilities
    
    Partial Public Class CodeOnly
        Inherits System.Web.UI.Page
    
    
    
        Private Sub CodeOnly_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
    
            Dim ScriptManager1 As New ScriptManager
            Page.Form.Controls.AddAt(0, ScriptManager1)
    
        End Sub
    
        Dim north As New Panel
        Dim west As New Panel
        Dim center As New Panel
        Dim east As New Panel
        Dim south As New Panel
        Dim BorderLayout1 As New BorderLayout
        Dim ViewPort1 As New ViewPort
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
          
            CreatePage(True, True, True, True, True)
    
        End Sub
    
        Protected Sub CreatePage(ByVal NorthActive As Boolean, ByVal SouthActive As Boolean, ByVal EastActive As Boolean, ByVal WestActive As Boolean, ByVal CenterActive As Boolean)
            CreatePanels(NorthActive, SouthActive, EastActive, WestActive, CenterActive)
            CreateBorderLayout(NorthActive, SouthActive, EastActive, WestActive, CenterActive)
            CreateViewPort()
        End Sub
    
        Protected Sub CreatePanels(ByVal NorthActive As Boolean, ByVal SouthActive As Boolean, ByVal EastActive As Boolean, ByVal WestActive As Boolean, ByVal CenterActive As Boolean)
    
            ' Create all Panels First so they can be used by parent objects
    
            ' Create Panel for North
            If NorthActive = True Then
                north.ID = "NorthPanel"
                north.Title = "North"
                north.Height = Unit.Pixel(150)
                north.BodyStyle = "padding:20px;"
                north.Html = "North"
            End If
    
            ' Create Panel for West
            If WestActive = True Then
                west.ID = "WestPanel"
                west.Title = "West"
                west.Width = Unit.Pixel(225)
            End If
    
            ' Create Panel for Center
            If CenterActive = True Then
                center.ID = "CenterPanel"
                center.Title = "center"
            End If
    
            Dim ToolBar As New Toolbar
            Dim Tool As New Button
    
            ToolBar.Items.Add(Tool)
    
            east.Items.Add(ToolBar)
    
    
            ' Create Panel for East
            If EastActive = True Then
                east.ID = "EastPanel"
                east.Title = "East"
                east.Width = Unit.Pixel(225)
            End If
    
            ' Create Panel for South
            If SouthActive = True Then
                south.ID = "SouthPanel"
                south.Title = "South"
                south.Height = Unit.Pixel(150)
                south.BodyStyle = "padding:20px;"
                south.Html = "South"
            End If
        End Sub
    
        Protected Sub CreateBorderLayout(ByVal NorthActive As Boolean, ByVal SouthActive As Boolean, ByVal EastActive As Boolean, ByVal WestActive As Boolean, ByVal CenterActive As Boolean)
    
            ' Setup North
            BorderLayout1.North.Collapsible = True
            BorderLayout1.North.Split = True
    
    
            ' Setup East
            BorderLayout1.East.MinWidth = Unit.Pixel(225)
            BorderLayout1.East.Collapsible = True
            BorderLayout1.East.Split = True
    
    
            ' Setup South
            BorderLayout1.South.Collapsible = True
            BorderLayout1.South.Split = True
    
    
            ' Setup West
            BorderLayout1.West.MinWidth = Unit.Pixel(225)
            BorderLayout1.West.MaxWidth = Unit.Pixel(400)
            BorderLayout1.West.Collapsible = True
            BorderLayout1.West.Split = True
    
            ' Setup Center - Nothing here yet!
    
    
    
            BorderLayout1.North.Items.Add(north)
            BorderLayout1.West.Items.Add(west)
            BorderLayout1.Center.Items.Add(center)
            BorderLayout1.East.Items.Add(east)
            BorderLayout1.South.Items.Add(south)
        End Sub
    
        Protected Sub CreateViewPort()
            ViewPort1.BodyControls.Add(BorderLayout1)
            PlaceHolder1.Controls.Add(ViewPort1)
        End Sub

    This is the addition that I am making to the Tab (FitLayout1) created above. This also works, but does a postback and refreshes the screen instead of just adding the content to the tab.


    CodeOnly.vb Function

    
        Protected Sub portalAdd()
    
            Dim FitLayout1 As New FitLayout
            FitLayout1.ID = "FitLayout1"
    
            center.Items.Add(FitLayout1)
    
            Dim Portal1 As New Portal
            Portal1.Title = "Portal 1"
            Portal1.Header = False
            FitLayout1.Items.Add(Portal1)
    
            Dim ColumnLayout1 As New ColumnLayout
            Portal1.Items.Add(ColumnLayout1)
    
            Dim LayoutColumn1 As New LayoutColumn
            LayoutColumn1.ColumnWidth = ".33"
            ColumnLayout1.Columns.Add(LayoutColumn1)
    
            Dim LayoutColumn2 As New LayoutColumn
            LayoutColumn2.ColumnWidth = ".33"
            ColumnLayout1.Columns.Add(LayoutColumn2)
    
            Dim LayoutColumn3 As New LayoutColumn
            LayoutColumn3.ColumnWidth = ".33"
            ColumnLayout1.Columns.Add(LayoutColumn3)
    
    
            Dim PortalColumn1 As New PortalColumn
            PortalColumn1.StyleSpec = "padding:10px 0 10px 10px"
            PortalColumn1.ID = "PortalColumn1"
            LayoutColumn1.Items.Add(PortalColumn1)
    
            Dim PortalColumn2 As New PortalColumn
            PortalColumn2.StyleSpec = "padding:10px 0 10px 10px"
            PortalColumn2.ID = "PortalColumn2"
            LayoutColumn2.Items.Add(PortalColumn2)
    
            Dim PortalColumn3 As New PortalColumn
            PortalColumn3.StyleSpec = "padding:10px 0 10px 10px"
            PortalColumn3.ID = "PortalColumn3"
            LayoutColumn3.Items.Add(PortalColumn3)
    
            Dim AnchorLayout1 As New AnchorLayout
            AnchorLayout1.ID = "AnchorLayout1"
            PortalColumn1.Items.Add(AnchorLayout1)
    
            Dim AnchorLayout2 As New AnchorLayout
            AnchorLayout2.ID = "AnchorLayout2"
            PortalColumn2.Items.Add(AnchorLayout2)
    
            Dim AnchorLayout3 As New AnchorLayout
            AnchorLayout3.ID = "AnchorLayout3"
            PortalColumn3.Items.Add(AnchorLayout3)
    
            'Add Anchors to AnchorLayout - One Anchor to one Portlet
            Dim Anchor1 As New Anchor
            AnchorLayout1.Anchors.Add(Anchor1)
    
            Dim Anchor2 As New Anchor
            AnchorLayout2.Anchors.Add(Anchor2)
    
            Dim Anchor3 As New Anchor
            AnchorLayout3.Anchors.Add(Anchor3)
    
            Dim Anchor4 As New Anchor
            AnchorLayout3.Anchors.Add(Anchor4)
    
    
            Dim Portlet1PH As New Portlet
            Portlet1PH.ID = "Portlet1PH"
            Portlet1PH.Title = "Portlet 1PH"
            Anchor1.Items.Add(Portlet1PH)
    
            Dim Portlet2PH As New Portlet
            Portlet2PH.ID = "Portlet2"
            Portlet2PH.Title = "Portlet 2PH"
            Anchor2.Items.Add(Portlet2PH)
    
            Dim Portlet3PH As New Portlet
            Portlet3PH.ID = "Portlet3PH"
            Portlet3PH.Title = "Portlet 3PH"
            Portlet3PH.Height = "200"
            Anchor3.Items.Add(Portlet3PH)
    
            Dim Portlet4PH As New Portlet
            Portlet4PH.ID = "Portlet4PH"
            Portlet4PH.Title = "Portlet 4PH"
            Portlet4PH.Height = "200"
            Anchor4.Items.Add(Portlet4PH)
    
            'Works non ajax
            ' Dim Button As New Button
            'Button.ID = "Button1"
            'Button.Text = "Button 1"
            'Button.Icon = Icon.ApplicationDelete
            'Button.Visible = True
            'Button.Listeners.Click.Handler = "alert('Clicked');"
            'Portlet4PH.Buttons.Add(Button)
    
    
            Dim Anchor5 As New Anchor
            AnchorLayout3.Anchors.Add(Anchor5)
            Dim Portlet1 As New Portlet
            Portlet1.ID = "Portlet1"
            Portlet1.Title = "Portlet 1"
            Anchor5.Items.Add(Portlet1)
    
            'Dim ToolBar1 As New Toolbar
            'Dim ToolButton As New SplitButton
            'ToolButton.ID = "ToolButton"
            'ToolButton.Icon = Icon.Add
            'ToolButton.Handler = "AddPortlet(#{none}, #{none});"
    
        End Sub


    Thanks Again

Similar Threads

  1. How to maintain page index after postback.
    By itskvini in forum 1.x Help
    Replies: 3
    Last Post: Jul 05, 2012, 1:27 PM
  2. [CLOSED] Cross-page Postback
    By alliedwallet.com in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 16, 2011, 1:19 PM
  3. Replies: 6
    Last Post: Oct 13, 2011, 9:51 PM
  4. Ext control invisible after postback of page.
    By Rupesh in forum 1.x Help
    Replies: 7
    Last Post: Sep 17, 2010, 5:11 AM
  5. [CLOSED] PostBack inside autoloaded page
    By Rod in forum 1.x Help
    Replies: 3
    Last Post: Sep 26, 2008, 6:40 AM

Posting Permissions