popup for a button

4 posts, 0 answers
  1. Bibhukalyana
    Bibhukalyana avatar
    4 posts
    Member since:
    Jan 2012

    Posted 02 Feb 2012 Link to this post

    Hi everyone,
                    I want to create a popup for a button.When I click the button the popup will open having some checkbox which is created in server dynamically.I am able to create the checkbox and popup.But the popup is visible in between i click the left click and click release.Can any one tell me how i will show the popup after the click event.

    protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                create_Items();
            }
        }
     
        protected void RadButton1_Click(object sender, EventArgs e)
        {
            create_Items();              
        }
     
        private void create_Items()
        {
            panel1.Controls.Clear();
            int i;
            for (i = 0; i < 5; i++)
            {
                CheckBox cb = new CheckBox();
                cb.ID = "cb" + i.ToString();
                cb.Text = "Checkbox" + i.ToString();
                popcontrol1.TargetControlID = "RadButton1";
                popcontrol1.PopupControlID = "panel1";
                popcontrol1.Position = AjaxControlToolkit.PopupControlPopupPosition.Bottom;
                panel1.Controls.Add(cb);
            }
        }


    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    <
    html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>   
        <form id="form1" runat="server">
        <asp:ScriptManager ID = "ScriptManager1" runat = "server"></asp:ScriptManager>
        <div>
        </div>
        <telerik:RadButton ID="RadButton1" runat="server" onclick="RadButton1_Click"
            Text="RadButton">
        </telerik:RadButton>
        <cc1:PopupControlExtender ID="popcontrol1" runat="server" TargetControlID="RadButton1"
            PopupControlID="panel1" Position="Bottom" />
                 
         
        <asp:Panel ID="panel1" runat="server" BackColor="#ccffff" Height="182px" Width="211px">
        </asp:Panel>
                
                 
            <telerik:RadButton ID="RadButton3" runat="server" Text="RadButton">
        </telerik:RadButton>
     
        </form>
    </body>
    </html>


    with regards
    bibhu.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 02 Feb 2012 Link to this post

    Hello,

    One suggestion is you can use RadWindow as popup as shown.
    ASPX:
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
       <Windows>
          <telerik:RadWindow ID="RadWindow1" runat="server">
          </telerik:RadWindow>
       </Windows>
    </telerik:RadWindowManager>
    C#:
    protected void Page_Load(object sender, EventArgs e)
       {
          // adding checkbox inside RadWindow
           CheckBox CheckBox1= new CheckBox();
           CheckBox1.Checked = true;
           RadWindow1.ContentContainer.Controls.Add(CheckBox1);
       }
    protected void btn1_Click(object sender, EventArgs e)
      {
         RadWindow1.VisibleOnPageLoad = true;
      }

    Thanks,
    Princy.
  3. Bibhukalyana
    Bibhukalyana avatar
    4 posts
    Member since:
    Jan 2012

    Posted 02 Feb 2012 Link to this post

    Hi Princy,
            Thanks.It is working.
    But i want to create a popup which will created near the button.
    How i will create it near button ?
    Can you tell me how to close popup in clientside ?

    with regards,
    bibhu.
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Feb 2012 Link to this post

    Hello,

    You can use moveTo method to position the window. Here is the sample code.
    JS:
      function OnClientClick()
        {
           var ownd = window.radopen(null, "RadWindow1");
           ownd.moveTo("100px", "50px"); // to postion the window.
        }
     
    //close window on client side
      function Close_Window()
       {
            var win = $find('<%=RadWindow1.ClientID %>');
            win.close();
       }

    Thanks,
    Princy.
Back to Top