-
Ajax UpdatePanel
Hi guys, how do i use AJAX updatePanel from default.aspx to display information from other aspx pages(e.g. default1.aspx) when i click on a button in default.aspx ? or is there any other ways so that i can achieve that ? examples on how to do it are greatly appreciated ...
-
Re: Ajax UpdatePanel
Make the content from other pages into a UserControl instead of a full page.
That should make it easier to place within your update panel.
UserControls are good when you want to reuse the content in more than one page.
-
Re: Ajax UpdatePanel
In general when developing a Web App, I personally create only one Main .ASPX page, and generate all the others needed as user control (.ASCX) pages..
Of course this requires you to switch in and out the controls depending on the page parameters passed, however once you get the hang of it it's relatively easy ..
Some sample code
MAIN.ASPX Designer
Code:
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Main.aspx.vb" Inherits="Forums.Main" %>
<%@ Register src="Header.ascx" tagname="Header" tagprefix="uc1" %>
<%@ Register src="Catalogs.ascx" tagname="Catalogs" tagprefix="uc2" %>
<%@ Register src="Topics.ascx" tagname="Topics" tagprefix="uc4" %>
<%@ Register src="Posts.ascx" tagname="Posts" tagprefix="uc5" %>
<%@ Register src="NewPost.ascx" tagname="NewPost" tagprefix="uc6" %>
<%@ Register src="Footer.ascx" tagname="Footer" tagprefix="uc3" %>
<asp:Panel Width="100%">
<uc1:Header ID="Header1" runat="server" />
<uc2:Catalogs ID="Catalogs1" runat="server" />
<uc4:Topics ID="Topics1" runat="server" />
<uc5:Posts ID="Posts1" runat="server" />
<uc6:NewPost ID="NewPost1" runat="server" />
<uc3:Footer ID="Footer1" runat="server" />
</asp:Panel>
And then in the Code
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
UserAgent = Request.ServerVariables("http_user_agent")
'get last IP
LastIp = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If Not LastIp Is Nothing Then
FIps = Split(LastIp, ",", -1, CompareMethod.Text)
LastIp = FIps(FIps.Length - 1)
Else
LastIp = Request.ServerVariables("REMOTE_ADDR")
End If
If Not IsPostBack Then
If Request.QueryString("Cat") IsNot Nothing Then
Catalogs1.Visible = True
ElseIf Request.QueryString("Group") IsNot Nothing Then
Catalogs1.Visible = True
ElseIf Request.QueryString("Do") IsNot Nothing Then
NewPost1.Visible = True
Footer1.Visible = False
ElseIf Request.QueryString("Forum") IsNot Nothing Then
Topics1.Visible = True
ElseIf Request.QueryString("Topic") IsNot Nothing Then
Posts1.Visible = True
Footer1.Visible = False
ElseIf Request.QueryString("Reply") IsNot Nothing Then
Posts1.Visible = True
Footer1.Visible = False
Else
Catalogs1.Visible = True
End If
End If
End Sub