hello
is there a way to set a default button inside update panel ?
thank u,
Hi,
UpdatePanel doesn't support this behavior directly, you can achieve this by adding a panel inside the UpdatePanel.
Then place all controls inside the UpdatePanel into the Panel. And set defaultButton on the panel.
For instance:
<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Button1_Click(object sender, EventArgs e) { TextBox1.Text = DateTime.Now.ToString(); } protected void Button2_Click(object sender, EventArgs e) { TextBox2.Text = DateTime.Now.ToString(); }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:panel ID="Panel1" runat="server" height="50px" width="125px" DefaultButton="Button1"> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </asp:panel> </ContentTemplate> </asp:UpdatePanel> <asp:panel runat="server" ID="Panel2" height="50px" width="125px" DefaultButton="Button2"> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" /> </asp:panel> </form></body></html>
No comments:
Post a Comment