So, I have a usercontrol with an update panel. I also put a button for updating the panel on my control. I include this control 2 times (or more) in a page. I want update only one of them but when I use the button, both panel is updated.
control ascx
<script type="text/javascript">
function bt_click()
{
__doPostBack( UpdatePanel1 , post );
return false;
}
</script>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:HiddenField runat="server" ID="HiddenField1" Value="false" />
<div>
<asp:Label ID="Label1" runat="server" Text="Val"></asp:Label>
</div>
</ContentTemplate>
</asp:UpdatePanel>
控制.vb
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
Label1.Text = DateTime.Now.Ticks.ToString();
}
}
网络格式.aspx
<form id="form1" runat="server">
<div>
<asp:Button runat="server" ID="bt" OnClientClick="bt_click" />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Label ID="Label1" runat="server" Text="Val"></asp:Label>
<div>
<My:MyControl ID="MyControl1" runat="server" />
</div>
<br />
<div>
<My:MyControl ID="MyControl2" runat="server" />
</div>
</div>
</form>
网址:vb
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
Label1.Text = DateTime.Now.Ticks.ToString();
}