Radwindow on Link button event

6 posts, 1 answers
  1. Neetha
    Neetha avatar
    36 posts
    Member since:
    Feb 2014

    Posted 23 Apr 2014 Link to this post

    I have a Link button in rad grid template column, on clicking on link i should get a radpopup window. Tried on the clientside not working then tried on server side too .. no luck.
    server side event:
     <telerik:GridTemplateColumn UniqueName="MetricGroup" DataField="MetricGroup">
                        <ItemTemplate>                         
                             <asp:LinkButton ID="lnkMetricGroup" runat="server"  OnClick="lnkMetricGroup_Click"
                                    Text='<%# DataBinder.Eval(Container.DataItem,"MetricGroup") %>'></asp:LinkButton>   
                   
                        </ItemTemplate>
          protected void lnkMetricGroup_Click(object sender, EventArgs e)
            {
                string name = "";
                LinkButton btn = (LinkButton)sender;
                name = btn.Text;               
                String url = "SalesActivity.aspx?MetricGroup=" + name;
                UserListDialog.NavigateUrl = url;
             }  

     <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true">
            <Windows>
                <telerik:RadWindow ID="UserListDialog" runat="server" Title="Details" Height="320px"
                    Width="310px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false"
                    Modal="true">
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>


    Please let me know on how to proceed on this.

    Thanks.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 24 Apr 2014 in reply to Neetha Link to this post

    Hi Neetha,

    Please try the following code snippet to open window on a LinkButton.

    ASPX:
    <asp:LinkButton ID="lnkMetricGroup" runat="server" OnClientClick="return OpenWindow();"
    Text='<%# DataBinder.Eval(Container.DataItem,"MetricGroup") %>' ></asp:LinkButton>

    JS:
    <script type="text/javascript">
        function OpenWindow() {
            var win = $find("<%=UserListDialog.ClientID %>");
            win.show();
            return false;
        }
    </script>

    Thanks,
    Princy
  3. Neetha
    Neetha avatar
    36 posts
    Member since:
    Feb 2014

    Posted 24 Apr 2014 in reply to Princy Link to this post

    This is not working, page just reloads when i click on link button, I supplied URL to it but no luck.

    Anyways i got it working through code behind.. Thanks.
     
    protected void lnkMetricGroup_Click(object sender, EventArgs e)
            {
                string name = "";
                LinkButton btn = (LinkButton)sender;
                name = btn.Text;               
              
               String url = "SalesActivity.aspx?MetricGroup=" + name;
               RadWindow window1 = new RadWindow();
               window1.NavigateUrl = url;
               window1.VisibleOnPageLoad = true;
               window1.ID = "RadWindow1";
               window1.Width = 500;
               window1.Height = 300;
               RadWindowManager1.Windows.Add(window1);

              
            }
  4. Neetha
    Neetha avatar
    36 posts
    Member since:
    Feb 2014

    Posted 24 Apr 2014 in reply to Neetha Link to this post

    Hi Princy,

    I got it working with above code but when i added AjaxManager only first click on the first row is working and rad window comes u fine but not for remaining. Here is my code:
     <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        </telerik:RadWindowManager>

    <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="lnkMetricGroup">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" LoadingPanelID="LoadingPanel1"></telerik:AjaxUpdatedControl>                      
                    </UpdatedControls>
                </telerik:AjaxSetting>     
            </AjaxSettings>

    <telerik:GridTemplateColumn UniqueName="MetricGroup" DataField="MetricGroup" HeaderText="Metric Group" HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>                        

                                <asp:LinkButton ID="lnkMetricGroup" runat="server" OnClick="lnkMetricGroup_Click"
                                    Text='<%# DataBinder.Eval(Container.DataItem,"MetricGroup") %>'></asp:LinkButton>
                               

                            </ItemTemplate>
                        </telerik:GridTemplateColumn>

      protected void lnkMetricGroup_Click(object sender, EventArgs e)
            {

                string name = "";
                LinkButton btn = (LinkButton)sender;
                name = btn.Text;
                String url = "SalesActivity.aspx?MetricGroup=" + name;
                RadWindow window1 = new RadWindow();
                window1.NavigateUrl = url;
                RadWindowManager1.EnableViewState = false;
                window1.Modal = true;          
                window1.ReloadOnShow = false;           
                window1.VisibleOnPageLoad = true;
                window1.ID = "RadWindow1";
                window1.Width = 500;
                window1.Height = 300;
                RadWindowManager1.Windows.Add(window1);
                window1.DestroyOnClose = true;
            }

    Please let me know what is wrong here? Thanks.


  5. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Apr 2014 in reply to Neetha Link to this post

    Hi Neetha,

    Since you are using server code to open the window it requires a call to the server side hence, we cant have the Ajax set to the button alone. You can ajaxify the grid as shown below. If you do not want postabck during the opening of window you have to open window from clientside.

    ASPX:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="gridLoadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" LoadingPanelID="gridLoadingPanel">
                    </telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel runat="server" ID="gridLoadingPanel">
    </telerik:RadAjaxLoadingPanel>

    Thanks,
    Princy
  6. Arun
    Arun avatar
    3 posts
    Member since:
    Jun 2017

    Posted 28 Jul 2017 in reply to Princy Link to this post

    hey Princy,

    Please tell me that why did you write return in OnClientClick event ?

    <asp:LinkButton ID="lnkMetricGroup" runat="server" OnClientClick="return OpenWindow();"
    Text='<%# DataBinder.Eval(Container.DataItem,"MetricGroup") %>' ></asp:LinkButton>

     

Back to Top