开发者

How to enable/disable link button from another control which is in update panel?

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate> 
    <div>                     
        <asp:DropDownList runat="server" EnableViewState="true" DataTextField="Name" DataValueField="Id"  DataSourceID="ListSource"  ID="List"            OnDataBound="List_OnDataBound" AutoPostBack="True" OnSelectedIndexChanged="List_SelectedIndexChanged">
        </asp:DropDownList>
    </div>
    </ContentTemplate>
        <Triggers>
        <asp:AsyncPostBackTrigger Control开发者_如何学编程ID="List2" EventName="SelectedIndexChanged" />
        <asp:AsyncPostBackTrigger ControlID="List" EventName="SelectedIndexChanged" />
        </Triggers>
    </asp:UpdatePanel>

on List_SelectedIndexChanged i am enabling/disabling anothe link button which is not in update panel but it is not working. i dont want to put linkbutton on update panel because on its click i want full page post back.


this is solution for you : How to update controls which are outside of updatepanel during partial page rendering?

The solutions is to use ScriptManager.RegisterDataItem() .

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode=Conditional>
           <ContentTemplate>
               <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
               <asp:Button ID="Button1" runat="server" Text="Update Button"  onclick="Button1_Click" />
           </ContentTemplate>      </asp:UpdatePanel>
    <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>


protected void Button1_Click(object sender, EventArgs e)
      {
         //Updating Label1 Text with the current Time Ticks
          Label1.Text = DateTime.Now.Ticks.ToString();
          //Register Label2 control with current DataTime as DataItem
          ScriptManager1.RegisterDataItem(Label2, DateTime.Now.ToString());
      }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜