-
August 3rd, 2011, 08:50 AM
#1
ASP.NET Update Panels With Page Manipulation Logic
I was hoping for some help with a UpdatePanel issue. I have read alot that they can be quite troublesome but this one has me baffled.
If i put two update panels on a page, one having triggers that affect the controls inside it then all is fine and the panels work as they should. However if i put some VB code around one of the UpdatePanel and tell it not to display on the page. Then the other stops working. Is there any reason for this? Is this not the correct way to use logic for page manipulation?
ASP Code:
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site1.Master" CodeBehind="NewOrder.aspx.vb" Inherits="WebApplication1.NewOrder" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:ScriptManager ID="ScriptManager" runat="Server" />
<%If False Then%>
<asp:updatepanel id="Updatepanel1" runat="server">
<ContentTemplate>
<asp:Label ID="LB1" Text="Label1" runat="server" />
</ContentTemplate>
</asp:updatepanel>
<%End If%>
<asp:updatepanel id="Updatepanel2" runat="server">
<ContentTemplate>
<asp:TextBox id="TB1" AutoPostBack="true" runat="server"/>
<asp:TextBox id="TB2" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID = "TB1" />
</Triggers>
</asp:updatepanel>
</asp:Content>
VB.NET Code:
Public Class NewOrder
Inherits System.Web.UI.Page
Protected Sub TB1_TextChanged(sender As Object, e As EventArgs) Handles TB1.TextChanged
TB2.Text = TB1.Text
End Sub
End Class
If you change the line <%If False Then%> to <%If True Then%> then all works fine and dandy, otherwise total failure.
Any help would be greatly appreciated on this one.
Thanks
Chris
-
August 3rd, 2011, 12:30 PM
#2
Re: ASP.NET Update Panels With Page Manipulation Logic
#1 : Please use code tags when posting code snips.. [code] Your Code [/code]
#2 : If statements require a condition ( IF {Condition} then) and a condition is normally something along the lines of IF A = B ... With If False the panel will NEVER be visible...
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
August 4th, 2011, 03:41 AM
#3
Re: ASP.NET Update Panels With Page Manipulation Logic
#1 : I would have done if when posting this message it actually said anywhere thats how to post code, this is my first post and if you check the thread creation tool, where does it say to use code blocks?
#2 : You are completely missing the point. I know that IF False will always be false, this is not what i am querying. I am trying to explain that when that IF statement is set to always be false, the other update panel on the page stops working.
-
August 5th, 2011, 02:58 AM
#4
Re: ASP.NET Update Panels With Page Manipulation Logic
If you look at the TOP MOST topic .. in the forum ..
Announcement: Before you post....
It has a section pertaining to Posting code......
Including Code
If you include listings within your messages, please use the button or code tags from within the message editors. This will format your code using a non-proportional font and it will preserve spacing. Most importantly, will make your code easier to read.
Rerturning to your Problem..
Generally i prefer to Hide panels via Page load code...
Code:
Protected Sub Page_load (ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If {condition} then
Updatepanel1.Visible = False
End If
.............
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
August 9th, 2011, 05:11 AM
#5
Re: ASP.NET Update Panels With Page Manipulation Logic
Yea thanks, i've pretty much come to the same conclusion. Haven't got a clue why it didn't work in the markup. Guess its just another UpdatePanel workaround.
Cheers for your help.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|