You must Sign In to post a response.
  • Category: ASP.NET

    Label inside popup display text in second time of click


    I want to show the popup on repeater control button click. Text for label will get generate in run time only. When i click the Repeater control button for first time label text is not showing but when i click the second time label is displaying. each time when i click, On second time click only popup showing the label text.

    Thanks in advance
  • #763063

    Check your code visible true or false setting before rendering code . can your share your code then only easily identify what is your issue

    Name : Dotnet Developer-2015
    Email Id :

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #763068

    Please find the code sample.


    <html xmlns="">
    <head runat="server">
    <script type="text/javascript" >
    function OpenNewPopupWindow()
    {"frmPopupWindow.aspx", "_blank", "toolbar=no, scrollbars=no, resizable=yes, top=500, left=500, width=400, height=400", true);
    return false;
    <form id="form1" runat="server">
    <asp:Repeater ID="rpUserDetails" runat="server" OnItemDataBound="rpUserDetails_ItemDataBound" >
    <asp:Label runat="server" ID="Label1"
    Text='<%# Eval("UserName") %>' />
    <asp:Label runat="server" ID="Label2"
    Text='<%# Eval("UserRole") %>' />
    <td><asp:Button ID="btnOpenPopup" Text="Open Popup Window" runat="server" /> </td>



    protected void Page_Load(object sender, EventArgs e)

    private void BindGrid()
    DataTable dt = new DataTable("UserDetails");

    DataRow dr;
    dr = dt.NewRow();
    dr["UserName"] = "Subash";
    dr["UserRole"] = "ProjectManager";
    dr = dt.NewRow();
    dr["UserName"] = "Bhagat";
    dr["UserRole"] = "TeamLeader";
    rpUserDetails.DataSource = dt;

    protected void rpUserDetails_ItemDataBound(object sender, RepeaterItemEventArgs e)
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    Button btn = (Button) e.Item.FindControl("btnOpenPopup");
    btn.Attributes.Add("onclick", "return OpenNewPopupWindow();");

    Happy Coding

  • #763125
    Hello Sudha,

    You can do it by using AJAX Modal Popup.

    First put controls inside repeater control and add one button so that on click of button you can the value into modal popup.

    add one modal popup and set the TargetControlID, PopupControlID="Panel1" and Drag="false"

    Add this code :
    <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup">
    Name : <asp:Label ID="LabelName" runat="server" Font-Names="Segoe UI" ForeColor="Red"></asp:Label><br />
    Class  : <asp:Label ID="LabelClass" runat="server" Font-Names="Segoe UI" ForeColor="Red"></asp:Label><br />
    <asp:Button ID="ButtonHide" runat="server" Text="Close" Font-Names="Segoe UI" OnClick="ButtonHide_Click"/>

    Code to set the value in modal popup on button click :
    Button button = (sender as Button);
    string commandArgument = button.CommandArgument;
    RepeaterItem item = button.NamingContainer as RepeaterItem;
    int index = item.ItemIndex;
    Label lbl1 = Repeater1.Items[index].FindControl("Label1") as Label;
    Label lbl2 = Repeater1.Items[index].FindControl("Label2") as Label;

    LabelName.Text = lbl1.Text;
    LabelClass.Text = lbl2.Text;

    hope this will help you.

    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • Sign In to post your comments