This is a migrated thread and some comments may be shown as answers.

popup for a button

3 Answers 171 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Bibhukalyana
Top achievements
Rank 1
Bibhukalyana asked on 02 Feb 2012, 01:54 PM
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.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Feb 2012, 02:07 PM
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.
0
Bibhukalyana
Top achievements
Rank 1
answered on 03 Feb 2012, 05:46 AM
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.
0
Princy
Top achievements
Rank 2
answered on 03 Feb 2012, 06:07 AM
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.
Tags
Ajax
Asked by
Bibhukalyana
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Bibhukalyana
Top achievements
Rank 1
Share this question
or