-2
페이지에 세 개의 업데이트 패널이 있습니다. 첫 번째 버튼을 제출할 때 첫 번째 updatepanel의 값만 표시하고 또 다른 updatepanel의 값은 받아 들여서는 안됩니다.동시에 여러 개의 업데이트 패널 업데이트
두 번째 updatepanel에서 두 번째 버튼을 클릭했을 때 두 번째 updatepanel의 값만 사용합니다. 뒤에
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ThreeUpdatepanel.aspx.cs" Inherits="ThreeUpdatepanel" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div><asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</div>
<br />
<asp:UpdatePanel ID="UpdatePanel3" runat="server" >
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<asp:TextBox id="TextBox1" runat="server">
</asp:TextBox>
<asp:Button ID="UPD1" runat="server" Text="UPD1" onclick="UPD1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<asp:TextBox id="TextBox2" runat="server">
</asp:TextBox>
<asp:Button ID="UPD2" runat="server" Text="UPD2" onclick="UPD2_Click" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="UPD1" EventName ="Click" />
<%--<asp:PostBackTrigger ControlID="UPD2" />--%>
</Triggers>
</asp:UpdatePanel>
</form>
</body>
</html>
코드 :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class ThreeUpdatepanel : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
}
}
protected void UPD1_Click(object sender, EventArgs e)
{
// My question is that when i click this button then also collected the value of another UpdatePanel(UpdatePanel2) TextBox(TextBox2.Text)
//Expected Result is TextBox2 value should be blank when i submit this button.
//UpdatePanel1.Update();
string x = TextBox2.Text;
Label1.Text = "You select: " + TextBox1.Text + ' ' + TextBox2.Text;
}
protected void UPD2_Click(object sender, EventArgs e)
{
// My question is that when i click this button then also collected the value of another UpdatePanel(UpdatePanel1) TextBox(TextBox1.Text)
//Expected Result is TextBox1 value should be blank when i submit this button.
//UpdatePanel2.Update();
string xx = TextBox1.Text;
Label1.Text = "You select: " + TextBox2.Text + ' ' +TextBox1.Text;
}
}
두 시간 업데이트 메시지가 세 번째 updatepanel의 라벨을 표시해야한다.
몇 가지 아이디어 나 해결책을 알려주세요. 여러 가지 방법으로이 작업을 수행 할 수 있습니다
버튼을 클릭 할 때 TextBox 값을 모두 사용합니다 !! 내 예상 결과가 아니야 ... 내 기대 결과는 ..입니다. 중요하지 않습니다. 첫 번째 버튼을 클릭했을 때 updatePanel1은 TextBox1의 값만 가져 오지만 TextBox2도 채워집니다. – sarfaraj