Created
December 20, 2017 16:04
-
-
Save diogobaltazar/08e82206e3654b74ab93ae03a4486217 to your computer and use it in GitHub Desktop.
ASP.NET UpdatePanel UpdateMode=Conditional
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="webForm1.aspx.cs" Inherits="aspnet_webapp.webForm1" %> | |
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head runat="server"> | |
<title>Pure asp.net testing </title> | |
</head> | |
<body> | |
<form id="form1" runat="server"> | |
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> | |
<asp:Table ID="tboutertable" runat="server"> | |
<asp:TableRow ID="tbr1"> | |
<asp:TableCell ID="tbc1" Text="Chose a value: "> | |
<asp:DropDownList ID="ddl" OnSelectedIndexChanged="ddl_SelectedIndexChanged" runat="server" AutoPostBack="true" /> | |
</asp:TableCell> | |
</asp:TableRow> | |
<asp:TableRow ID="tbr2"> | |
<asp:TableCell ID="tbcddl" Text="table-cell text here"> | |
</asp:TableCell> | |
</asp:TableRow> | |
<asp:TableRow ID="tbrcontainertbdadospessoais"> | |
<asp:TableCell> | |
<asp:UpdatePanel ID="udpdadospessoais" runat="server" UpdateMode="Conditional"> | |
<ContentTemplate> | |
<asp:Table ID="tbdadospessoais" runat="server"> | |
<asp:TableRow runat="server" ID="tbrnomecandidato"> | |
<asp:TableCell runat="server" CssClass="ms-formlabel" Width="30%" VerticalAlign="Top"> | |
<asp:Label ID="lblnomecandidato" runat="server" Text="Nome completo" /> | |
</asp:TableCell> | |
</asp:TableRow> | |
</asp:Table> | |
</ContentTemplate> | |
<Triggers> | |
<asp:AsyncPostBackTrigger ControlID="ddl" EventName="SelectedIndexChanged" /> | |
</Triggers> | |
</asp:UpdatePanel> | |
</asp:TableCell> | |
</asp:TableRow> | |
</asp:Table> | |
</form> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.UI; | |
using System.Web.UI.WebControls; | |
namespace aspnet_webapp | |
{ | |
public partial class webForm1 : System.Web.UI.Page | |
{ | |
protected void Page_Load(object sender, EventArgs e) | |
{ | |
if (!IsPostBack) { | |
tbrnomecandidato.Visible = false; | |
ddl.Items.Add("NULL"); | |
ddl.Items.Add("mostrar"); | |
ddl.Items.Add("esconder"); | |
} | |
} | |
protected void ddl_SelectedIndexChanged(object sender, EventArgs e) | |
{ | |
tbrnomecandidato.Visible = ddl.SelectedValue == "mostrar"; | |
udpdadospessoais.Update(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fazer o update a um updatepanel por um controlo externo ao updatepanel